package core import ( "github.com/bwmarrin/discordgo" "log" ) // represent a command to input to the bot through a Discord message type Command struct { name string // name identifier desc string // description example string // usage example command func( s *discordgo.Session, m *discordgo.MessageCreate, message string) // command (a callback) } // register containing commands associated with their aliases var CommandRegister = make( map[string]Command) // associate a Command with an alias within the command register func SetCommand( aliases []string, desc string, example string, command func(s *discordgo.Session, m *discordgo.MessageCreate, message string)) { for _, alias := range aliases { c := Command{ name: alias, desc: desc, example: example, command: command} CommandRegister[alias] = c log.Printf("added %s to Register", alias) } } // add commands to the register func CommandInit() { SetCommand( []string{"ggd audio", "ggd tts"}, "*Attach a TTS version of the message on the channel*", "`ggd [audio|tts] hello everyone`", MessageAudio) SetCommand( []string{"ggd voca"}, "Play audio message in vocal channel", "`ggd voca let's go shopping`", MessageVocal) SetCommand( []string{"ping", "pong"}, "*Check if the bot is alive*", "`[ping|pong]`", MessagePing) SetCommand( []string{"ggd help", "ggd info"}, "*Display the available list of commands*", "`ggd [help|info]`", MessageHelp) SetCommand( []string{"ggd hat", "ggd chapeau", "ggd chapo"}, "*Hand over a set of fancy hats*", "`ggd [hat|chapeau|chapo]`", MessageHat) }