remove slash commands

This commit is contained in:
Ryan Cavicchioni 2022-07-27 19:34:34 -05:00
parent df800efc90
commit cd783493c9
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

View File

@ -15,10 +15,9 @@ import (
"syscall" "syscall"
"git.kill0.net/chill9/beepboop/command" "git.kill0.net/chill9/beepboop/command"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
// log "github.com/golang/glog"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -28,44 +27,6 @@ var (
defaultReactions []string = []string{"👍", "🌶️", "🤣", "😂", "🍆", "🍑", "❤️", "💦", "😍", "💩", "🔥", "🍒", "🎉", "🥳", "🎊"} defaultReactions []string = []string{"👍", "🌶️", "🤣", "😂", "🍆", "🍑", "❤️", "💦", "😍", "💩", "🔥", "🍒", "🎉", "🥳", "🎊"}
commands = []*discordgo.ApplicationCommand{
{
Name: "poop",
Type: discordgo.ChatApplicationCommand,
Description: "Hot and steamy",
},
{
Name: "ping",
Type: discordgo.ChatApplicationCommand,
Description: "Ping the bot",
},
{
Name: "roll",
Type: discordgo.ChatApplicationCommand,
Description: "Roll a dice",
Options: []*discordgo.ApplicationCommandOption{
{
Type: discordgo.ApplicationCommandOptionString,
Name: "dice",
Description: "Dice specification e.g. d4 or 2d6",
Required: true,
},
},
},
{
Name: "coin",
Type: discordgo.ChatApplicationCommand,
Description: "Flip a coin",
},
}
commandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
"ping": command.PingCommand,
"poop": command.PoopCommand,
"roll": command.RollCommand,
"coin": command.CoinCommand,
}
config Config config Config
) )
@ -145,19 +106,6 @@ func main() {
log.Fatalf("error opening connection: %v\n", err) log.Fatalf("error opening connection: %v\n", err)
} }
for _, c := range commands {
_, err := dg.ApplicationCommandCreate(dg.State.User.ID, "", c)
if err != nil {
log.Errorf("Cannot create '%v' command %v", c.Name, err)
}
}
dg.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
if h, ok := commandHandlers[i.ApplicationCommandData().Name]; ok {
h(s, i)
}
})
log.Info("The bot is now running. Press CTRL-C to exit.") log.Info("The bot is now running. Press CTRL-C to exit.")
defer dg.Close() defer dg.Close()