From 8e430ad28ed3e6c0bd4536e69622a87a4dc8781f Mon Sep 17 00:00:00 2001 From: Riley Date: Tue, 13 Jul 2021 14:59:33 -0700 Subject: [PATCH] fix issue where tagging the bot would not give same results as using a prefix --- util.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util.go b/util.go index e8ee4f6..f3d1023 100644 --- a/util.go +++ b/util.go @@ -140,8 +140,15 @@ func ExtractCommand(guild *GuildInfo, message string) (*string, *string) { if content == "" { return nil, nil } - trigger := strings.ToLower(strings.Fields(content)[0]) + // Attempt to pull the trigger out of the command content by splitting on spaces + trigger := strings.Fields(content)[0] + + // With the trigger identified, split the command content on the trigger to obtain everything BUT the trigger + // Ensure only 2 fields are returned so it can be split further. Then, get only the second field fullArgs := strings.SplitN(content, trigger, 2)[1] + fullArgs = strings.TrimPrefix(fullArgs, " ") + // Avoids issues with strings that are case sensitive + trigger = strings.ToLower(trigger) return &trigger, &fullArgs } else { return nil, nil