mirror of
https://github.com/Xevion/r2park.git
synced 2026-01-31 08:25:22 -06:00
Enable ModalSubmit interactions, handler switch, default warning
This commit is contained in:
@@ -63,9 +63,43 @@ func Bot() {
|
|||||||
|
|
||||||
// Setup command handlers
|
// Setup command handlers
|
||||||
session.AddHandler(func(internalSession *discordgo.Session, interaction *discordgo.InteractionCreate) {
|
session.AddHandler(func(internalSession *discordgo.Session, interaction *discordgo.InteractionCreate) {
|
||||||
|
switch interaction.Type {
|
||||||
|
case discordgo.InteractionApplicationCommand, discordgo.InteractionApplicationCommandAutocomplete:
|
||||||
if handler, ok := commandHandlers[interaction.ApplicationCommandData().Name]; ok {
|
if handler, ok := commandHandlers[interaction.ApplicationCommandData().Name]; ok {
|
||||||
handler(internalSession, interaction)
|
handler(internalSession, interaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case discordgo.InteractionModalSubmit:
|
||||||
|
err := session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Content: "Registration data received. Please wait while your vehicle is registered.",
|
||||||
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
data := interaction.ModalSubmitData()
|
||||||
|
log.Debugf("Submitted: %v", data)
|
||||||
|
|
||||||
|
// if !strings.HasPrefix(data.CustomID, "modals_survey") {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// userid := strings.Split(data.CustomID, "_")[2]
|
||||||
|
// _, err = s.ChannelMessageSend(*ResultsChannel, fmt.Sprintf(
|
||||||
|
// "Feedback received. From <@%s>\n\n**Opinion**:\n%s\n\n**Suggestions**:\n%s",
|
||||||
|
// userid,
|
||||||
|
// data.Components[0].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value,
|
||||||
|
// data.Components[1].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value,
|
||||||
|
// ))
|
||||||
|
// if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
// }
|
||||||
|
default:
|
||||||
|
log.Warnf("Warning: Unhandled interaction type: %v", interaction.Type)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Setup signals before adding commands in case we CTRL+C before/during command registration
|
// Setup signals before adding commands in case we CTRL+C before/during command registration
|
||||||
|
|||||||
Reference in New Issue
Block a user