fix issue where tagging the bot would not give same results as using a prefix

This commit is contained in:
vel 2021-07-13 14:59:33 -07:00
parent c206ba21d1
commit 8e430ad28e
Signed by: velvox
GPG Key ID: 1C8200C1D689CEF5
1 changed files with 8 additions and 1 deletions

View File

@ -140,8 +140,15 @@ func ExtractCommand(guild *GuildInfo, message string) (*string, *string) {
if content == "" { if content == "" {
return nil, nil 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.SplitN(content, trigger, 2)[1]
fullArgs = strings.TrimPrefix(fullArgs, " ")
// Avoids issues with strings that are case sensitive
trigger = strings.ToLower(trigger)
return &trigger, &fullArgs return &trigger, &fullArgs
} else { } else {
return nil, nil return nil, nil