oups
This commit is contained in:
@@ -11,14 +11,20 @@ import (
|
||||
|
||||
// Router dispatches Discord interactions to the appropriate handler.
|
||||
type Router struct {
|
||||
PanelCmd *commands.PanelCommand
|
||||
TicketCmd *commands.TicketCommand
|
||||
ConvocCmd *commands.ConvocationCommand
|
||||
PanelComp *components.PanelComponent
|
||||
TicketComp *components.TicketComponent
|
||||
PanelCmd *commands.PanelCommand
|
||||
TicketCmd *commands.TicketCommand
|
||||
ConvocCmd *commands.ConvocationCommand
|
||||
PanelComp *components.PanelComponent
|
||||
TicketComp *components.TicketComponent
|
||||
ConvocComp *components.ConvocationComponent
|
||||
IsGuildAllowed func(guildID string) bool
|
||||
}
|
||||
|
||||
func (r *Router) Handle(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
if r.IsGuildAllowed != nil && !r.IsGuildAllowed(i.GuildID) {
|
||||
slog.Debug("ignoring interaction from unlisted guild", "guild_id", i.GuildID)
|
||||
return
|
||||
}
|
||||
switch i.Type {
|
||||
case discordgo.InteractionApplicationCommand:
|
||||
r.routeCommand(s, i)
|
||||
@@ -61,6 +67,10 @@ func (r *Router) routeComponent(s *discordgo.Session, i *discordgo.InteractionCr
|
||||
r.TicketComp.HandleDeleteCancel(s, i)
|
||||
case strings.HasPrefix(customID, "convoc:delete:"):
|
||||
r.TicketComp.HandleConvocationDelete(s, i)
|
||||
case strings.HasPrefix(customID, "convoc:panel:"):
|
||||
if r.ConvocComp != nil {
|
||||
r.ConvocComp.HandlePanel(s, i)
|
||||
}
|
||||
default:
|
||||
slog.Warn("unknown component", "custom_id", customID)
|
||||
}
|
||||
@@ -72,6 +82,10 @@ func (r *Router) routeModal(s *discordgo.Session, i *discordgo.InteractionCreate
|
||||
switch {
|
||||
case strings.HasPrefix(customID, "modal:ticket:"):
|
||||
r.PanelComp.HandleModalSubmit(s, i)
|
||||
case strings.HasPrefix(customID, "modal:convoc:"):
|
||||
if r.ConvocComp != nil {
|
||||
r.ConvocComp.HandleModalSubmit(s, i)
|
||||
}
|
||||
default:
|
||||
slog.Warn("unknown modal", "custom_id", customID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user