This repository has been archived by the owner on Jun 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Defines that usage of a command must be prefixed with a bot mention rather than the plugin's defined prefix. This involves having the plugin manager register CommandsNextExtension, and implementing a custom command handler which accounts for either plugin-defined prefix or mention prefix.
- Loading branch information
1 parent
e347fce
commit 0bb57c7
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
using DisCatSharp.CommandsNext; | ||
using DisCatSharp.CommandsNext.Attributes; | ||
|
||
namespace BrackeysBot.API.Attributes; | ||
|
||
/// <summary> | ||
/// Defines that usage of this command must require a bot mention prefix rather than the plugin's defined prefix. | ||
/// </summary> | ||
public sealed class RequireMentionPrefix : CheckBaseAttribute | ||
{ | ||
/// <inheritdoc /> | ||
public override Task<bool> ExecuteCheckAsync(CommandContext ctx, bool help) | ||
{ | ||
return Task.FromResult(MentionUtility.TryParseUser(ctx.Prefix[..^1], out ulong id) && id == ctx.Client.CurrentUser.Id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters