Refactor step 2
This commit is contained in:
parent
ddeaa5466c
commit
a986ae5906
34
handlers/basicCommands.go
Normal file
34
handlers/basicCommands.go
Normal file
@ -0,0 +1,34 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"kleincordBot/services"
|
||||
)
|
||||
|
||||
func ReadBackCommand(data discordgo.ApplicationCommandInteractionData, s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
func Test1Command(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
err := s.InteractionRespond(
|
||||
i.Interaction,
|
||||
&discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
services.HandleError(err)
|
||||
}
|
||||
}
|
||||
@ -12,29 +12,9 @@ func CommandRouter(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
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)
|
||||
}
|
||||
handlers.Test1Command(s, i)
|
||||
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)
|
||||
}
|
||||
handlers.ReadBackCommand(data, s, i)
|
||||
case "delete":
|
||||
handlers.DeleteCommand(data, s, i)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user