Initial split of the modules
This commit is contained in:
17
NadekoBot.Core/Common/Attributes/OwnerOnlyAttribute.cs
Normal file
17
NadekoBot.Core/Common/Attributes/OwnerOnlyAttribute.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class OwnerOnlyAttribute : PreconditionAttribute
|
||||
{
|
||||
public override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
|
||||
{
|
||||
var creds = (IBotCredentials)services.GetService(typeof(IBotCredentials));
|
||||
|
||||
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user