package handler import ( "fmt" "ticket-pimp/internal/controller" "ticket-pimp/internal/domain" "github.com/bwmarrin/discordgo" ) type router struct { Routes []route controller controller.WorkflowController conf *domain.DiscordConfig } // Подключение роутов к Discord боту func InitRouter(wc controller.WorkflowController, conf *domain.DiscordConfig) *router { var r router r.Routes = append( r.Routes, r.CreateRepoHandler(3), r.CreateFolderHandler(3), r.Ping(), r.CreateTicketHandler(3), r.InitProjectFromChannel(3), r.GetInfo(), ) r.controller = wc r.conf = conf return &r } type route struct { Command discordgo.ApplicationCommand Handler func(s *discordgo.Session, i *discordgo.InteractionCreate) } func (h *router) defaultFollowUp(answer string, s *discordgo.Session, i *discordgo.InteractionCreate) { // Sending result: _, err := s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: answer, }) if err != nil { s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ Content: fmt.Sprintf("Something went wrong: %v", err), }) return } }