Add unhanlded focus option for register command, improve both, comments

This commit is contained in:
2023-12-22 16:37:38 -06:00
parent 25158efd5a
commit e6da0d0fae

View File

@@ -96,14 +96,17 @@ func CodeCommandHandler(session *discordgo.Session, interaction *discordgo.Inter
}
}
default:
// An option was focused, but it does not have a handler.
var focusedOption *discordgo.ApplicationCommandInteractionDataOption
focusedIndex := 0
for i, option := range data.Options {
if option.Focused {
focusedOption = option
focusedIndex = i
break
}
}
log.WithFields(logrus.Fields{"focusedIndex": focusedIndex}).Warn("Unhandled autocomplete option")
log.WithFields(logrus.Fields{"focusedIndex": focusedIndex, "focusedOption": focusedOption.Name, "focusedOption.value": focusedOption.Value}).Warn("Unhandled autocomplete option")
return
}
@@ -278,6 +281,7 @@ func RegisterCommandHandler(session *discordgo.Session, interaction *discordgo.I
// },
// })
// Autocomplete is used to provide the user with a list of locations to choose from
case discordgo.InteractionApplicationCommandAutocomplete:
data := interaction.ApplicationCommandData()
var choices []*discordgo.ApplicationCommandOptionChoice
@@ -299,6 +303,20 @@ func RegisterCommandHandler(session *discordgo.Session, interaction *discordgo.I
Value: strconv.Itoa(int(location.id)),
}
}
default:
// An option was focused, but it does not have a handler.
var focusedOption *discordgo.ApplicationCommandInteractionDataOption
focusedIndex := 0
for i, option := range data.Options {
if option.Focused {
focusedOption = option
focusedIndex = i
break
}
}
log.WithFields(logrus.Fields{"focusedIndex": focusedIndex, "focusedOption": focusedOption.Name, "focusedOption.value": focusedOption.Value}).Warn("Unhandled autocomplete option")
}
err := session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{