Fix an issue where regex reactions would happen even if the regex doesn't match
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2024-01-13 19:08:39 -08:00
parent 53ecef743c
commit 3cc0003d65
2 changed files with 2 additions and 4 deletions

View File

@ -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))

View File

@ -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()