From 4a3e790767ca6f8033a8ca89afd70b7424fbf4ec Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 8 May 2023 17:29:39 +0100 Subject: [PATCH] feat(commands): add RequireBotOwnerAttribute --- .../ExecutionChecks/RequireBotOwnerAttribute.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 VpSharp.Commands/Attributes/ExecutionChecks/RequireBotOwnerAttribute.cs diff --git a/VpSharp.Commands/Attributes/ExecutionChecks/RequireBotOwnerAttribute.cs b/VpSharp.Commands/Attributes/ExecutionChecks/RequireBotOwnerAttribute.cs new file mode 100644 index 0000000..d3a54cf --- /dev/null +++ b/VpSharp.Commands/Attributes/ExecutionChecks/RequireBotOwnerAttribute.cs @@ -0,0 +1,14 @@ +namespace VpSharp.Commands.Attributes.ExecutionChecks; + +/// +/// Specifies that this command can only be run by the user under whom this bot is authenticated. +/// +public sealed class RequireBotOwnerAttribute : PreExecutionCheckAttribute +{ + /// + protected internal override Task PerformAsync(CommandContext context) + { + ArgumentNullException.ThrowIfNull(context); + return Task.FromResult(context.Avatar.User.Id == context.Client.CurrentUser?.Id); + } +}