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