2017-07-17 21:42:36 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-09-30 04:20:09 +02:00
|
|
|
|
using Discord.Commands;
|
2017-10-13 06:14:54 +02:00
|
|
|
|
using NadekoBot.Core.Services;
|
2016-08-20 13:05:57 +02:00
|
|
|
|
|
2017-07-17 21:42:36 +02:00
|
|
|
|
namespace NadekoBot.Common.Attributes
|
2016-09-30 04:20:09 +02:00
|
|
|
|
{
|
|
|
|
|
public class OwnerOnlyAttribute : PreconditionAttribute
|
|
|
|
|
{
|
2017-05-23 01:59:31 +02:00
|
|
|
|
public override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
|
|
|
|
|
{
|
|
|
|
|
var creds = (IBotCredentials)services.GetService(typeof(IBotCredentials));
|
|
|
|
|
|
2017-05-24 22:28:16 +02:00
|
|
|
|
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
|
2017-05-23 01:59:31 +02:00
|
|
|
|
}
|
2016-09-30 04:20:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|