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":
|
case "init":
|
||||||
services.AddServer(i.GuildID, s)
|
services.AddServer(i.GuildID, s)
|
||||||
case "test1":
|
case "test1":
|
||||||
err := s.InteractionRespond(
|
handlers.Test1Command(s, i)
|
||||||
i.Interaction,
|
|
||||||
&discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
services.HandleError(err)
|
|
||||||
}
|
|
||||||
case "read_back":
|
case "read_back":
|
||||||
err := s.InteractionRespond(
|
handlers.ReadBackCommand(data, s, i)
|
||||||
i.Interaction,
|
|
||||||
&discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: data.Options[0].Value.(string),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
services.HandleError(err)
|
|
||||||
}
|
|
||||||
case "delete":
|
case "delete":
|
||||||
handlers.DeleteCommand(data, s, i)
|
handlers.DeleteCommand(data, s, i)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user