kleincordBot/routers/commandRouter.go
2024-05-03 21:25:42 +02:00

42 lines
951 B
Go

package routers
import (
"github.com/bwmarrin/discordgo"
"kleincordBot/handlers"
"kleincordBot/services"
)
func CommandRouter(s *discordgo.Session, i *discordgo.InteractionCreate) {
data := i.ApplicationCommandData()
switch data.Name {
case "init":
services.AddServer(i.GuildID, s)
case "test1":
err := s.InteractionRespond(
i.Interaction,
&discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{},
},
)
if err != nil {
services.HandleError(err)
}
case "read_back":
err := s.InteractionRespond(
i.Interaction,
&discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: data.Options[0].Value.(string),
},
},
)
if err != nil {
services.HandleError(err)
}
case "delete":
handlers.DeleteCommand(data, s, i)
}
}