From 3cc0003d65e8651466e159d3fbeb766fec8f4fec Mon Sep 17 00:00:00 2001 From: Elara6331 Date: Sat, 13 Jan 2024 19:08:39 -0800 Subject: [PATCH] Fix an issue where regex reactions would happen even if the regex doesn't match --- internal/systems/reactions/commands.go | 2 -- internal/systems/reactions/handlers.go | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/systems/reactions/commands.go b/internal/systems/reactions/commands.go index c77803d..6ea3d4c 100644 --- a/internal/systems/reactions/commands.go +++ b/internal/systems/reactions/commands.go @@ -105,11 +105,9 @@ func reactionsListCmd(s *discordgo.Session, i *discordgo.InteractionCreate) erro return err } - fmt.Println(reactions) var sb strings.Builder sb.WriteString("**Reactions:**\n") for _, reaction := range reactions { - fmt.Println(reaction.Reaction) sb.WriteString("- _[") if reaction.Chance < 100 { sb.WriteString(strconv.Itoa(reaction.Chance)) diff --git a/internal/systems/reactions/handlers.go b/internal/systems/reactions/handlers.go index 1ce075f..71c9c97 100644 --- a/internal/systems/reactions/handlers.go +++ b/internal/systems/reactions/handlers.go @@ -51,7 +51,7 @@ func onMessage(s *discordgo.Session, mc *discordgo.MessageCreate) { continue } - content := reaction.Reaction + var content db.StringSlice switch reaction.ReactionType { case db.ReactionTypeText: submatch := re.FindSubmatch([]byte(mc.Content)) @@ -72,7 +72,7 @@ func onMessage(s *discordgo.Session, mc *discordgo.MessageCreate) { } } - if content[0] != "" { + if content != nil { err = performReaction(s, reaction, content, mc) if err != nil { log.Error("Error performing reaction").Err(err).Send()