whoops broke buttons and modals
This commit is contained in:
18
handlers.go
18
handlers.go
@@ -65,27 +65,29 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
|
|||||||
|
|
||||||
func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
for _, command := range commands {
|
for _, command := range commands {
|
||||||
if i.ApplicationCommandData().Name == command.Definition.Name && !command.AllowDM && i.Interaction.GuildID == "" {
|
|
||||||
respond(i.Interaction, "This interaction is not available in DMs.", true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch i.Type {
|
switch i.Type {
|
||||||
case discordgo.InteractionApplicationCommand:
|
case discordgo.InteractionApplicationCommand:
|
||||||
if command.Interact != nil && i.ApplicationCommandData().Name == command.Definition.Name {
|
if command.Interact != nil && i.ApplicationCommandData().Name == command.Definition.Name {
|
||||||
|
if !command.AllowDM && i.Interaction.GuildID == "" {
|
||||||
|
respond(i.Interaction, "This command is not available in DMs.", true)
|
||||||
|
} else {
|
||||||
command.Interact(s, i)
|
command.Interact(s, i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case discordgo.InteractionApplicationCommandAutocomplete:
|
case discordgo.InteractionApplicationCommandAutocomplete:
|
||||||
if command.Autocomplete != nil && i.ApplicationCommandData().Name == command.Definition.Name {
|
if command.Autocomplete != nil && i.ApplicationCommandData().Name == command.Definition.Name && command.AllowDM && i.Interaction.GuildID != "" {
|
||||||
command.Autocomplete(s, i)
|
command.Autocomplete(s, i)
|
||||||
}
|
}
|
||||||
case discordgo.InteractionModalSubmit:
|
case discordgo.InteractionModalSubmit:
|
||||||
|
if !command.AllowDM && i.Interaction.GuildID == "" {
|
||||||
|
respond(i.Interaction, "This modal is not available in DMs.", true)
|
||||||
|
} else {
|
||||||
if command.ModalSubmit != nil {
|
if command.ModalSubmit != nil {
|
||||||
// FIXME: Makes it dynamic i don't know why it isn't otherwise
|
// FIXME: Makes it dynamic i don't know why it isn't otherwise
|
||||||
if command.Definition.Name == "form" {
|
if command.Definition.Name == "form" {
|
||||||
command.ModalIDs = getFormButtonIDs()
|
command.ModalIDs = getFormButtonIDs()
|
||||||
}
|
}
|
||||||
var hasID bool = false
|
var hasID bool = false
|
||||||
if command.ModalSubmit != nil {
|
|
||||||
for _, modalID := range command.ModalIDs {
|
for _, modalID := range command.ModalIDs {
|
||||||
if strings.HasPrefix(i.ModalSubmitData().CustomID, modalID) {
|
if strings.HasPrefix(i.ModalSubmitData().CustomID, modalID) {
|
||||||
hasID = true
|
hasID = true
|
||||||
@@ -97,6 +99,9 @@ func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case discordgo.InteractionMessageComponent:
|
case discordgo.InteractionMessageComponent:
|
||||||
|
if !command.AllowDM && i.Interaction.GuildID == "" {
|
||||||
|
respond(i.Interaction, "This component is not available in DMs.", true)
|
||||||
|
} else {
|
||||||
if command.ComponentInteract != nil {
|
if command.ComponentInteract != nil {
|
||||||
if command.Definition.Name == "form" {
|
if command.Definition.Name == "form" {
|
||||||
command.ComponentIDs = getFormButtonIDs()
|
command.ComponentIDs = getFormButtonIDs()
|
||||||
@@ -108,6 +113,7 @@ func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func removeOldCommandFromAllGuilds(s *discordgo.Session) {
|
func removeOldCommandFromAllGuilds(s *discordgo.Session) {
|
||||||
existingCommands, err := s.ApplicationCommands(s.State.User.ID, "")
|
existingCommands, err := s.ApplicationCommands(s.State.User.ID, "")
|
||||||
|
Reference in New Issue
Block a user