Support for commands without a prefix using new attribute NoPrefixRequired

This commit is contained in:
barelyprofessional
2026-01-13 21:53:27 -06:00
parent 295fef20fb
commit 3f4c3e2713

View File

@@ -47,14 +47,11 @@ internal class BotCommands
return;
}
if (!message.MessageRaw.StartsWith(CommandPrefix))
{
return;
}
var messageTrimmed = message.MessageRaw.TrimStart(CommandPrefix);
foreach (var command in Commands)
{
var noPrefixCommand = HasAttribute<NoPrefixRequired>(command);
if (!noPrefixCommand && !message.MessageRaw.StartsWith(CommandPrefix)) return;
foreach (var regex in command.Patterns)
{
var match = regex.Match(messageTrimmed);
@@ -252,4 +249,10 @@ internal class WagerCommand : Attribute;
/// It'll also check whether the user is permanently banned before running the command.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
internal class KasinoCommand : Attribute;
internal class KasinoCommand : Attribute;
/// <summary>
/// Use this on commands where the Regex should be tested even if there's no command prefix
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
internal class NoPrefixRequired : Attribute;