Added new rules concerning type constraints and :base() calls. Reformatted attributes folder

This commit is contained in:
Kwoth
2021-12-26 17:45:26 +01:00
parent d5fd6aae8e
commit 9ae030a5c5
10 changed files with 39 additions and 21 deletions

View File

@@ -5,10 +5,16 @@ namespace NadekoBot.Common.Attributes;
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class OwnerOnlyAttribute : PreconditionAttribute
{
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
public override Task<PreconditionResult> CheckPermissionsAsync(
ICommandContext context,
CommandInfo executingCommand,
IServiceProvider services)
{
var creds = services.GetRequiredService<IBotCredsProvider>().GetCreds();
return Task.FromResult(creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner"));
return Task.FromResult(creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id
? PreconditionResult.FromSuccess()
: PreconditionResult.FromError("Not owner")
);
}
}