1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-23 00:28:48 +00:00

feat(commands): add RequireBotOwnerAttribute

This commit is contained in:
Oliver Booth 2023-05-08 17:29:39 +01:00
parent 9171872ec4
commit 4a3e790767
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -0,0 +1,14 @@
namespace VpSharp.Commands.Attributes.ExecutionChecks;
/// <summary>
/// Specifies that this command can only be run by the user under whom this bot is authenticated.
/// </summary>
public sealed class RequireBotOwnerAttribute : PreExecutionCheckAttribute
{
/// <inheritdoc />
protected internal override Task<bool> PerformAsync(CommandContext context)
{
ArgumentNullException.ThrowIfNull(context);
return Task.FromResult(context.Avatar.User.Id == context.Client.CurrentUser?.Id);
}
}