Documentation
¶
Index ¶
- Variables
- func GetCmdDefs() []*discordgo.ApplicationCommand
- func GetCmdHandler() map[string]Command
- func GetComponentHandler() map[string]HandlerFunc
- func Register(c Command)
- func RegisterCommands(sess *discordgo.Session) (registeredCommands []*discordgo.ApplicationCommand)
- func RemoveCommands(sess *discordgo.Session, registeredCommands []*discordgo.ApplicationCommand)
- type Command
- type HandlerFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var CmdStore []Command
Contains all slash commands for this bot
Functions ¶
func GetCmdDefs ¶
func GetCmdDefs() []*discordgo.ApplicationCommand
// GetCmdDefs return all slash command definitions.
func GetCmdHandler ¶
GetCmdHandler returns a map of command name to all their handler function.
func GetComponentHandler ¶
func GetComponentHandler() map[string]HandlerFunc
GetComponentHandler returns a map of component ID and the handler function.
func RegisterCommands ¶
func RegisterCommands(sess *discordgo.Session) (registeredCommands []*discordgo.ApplicationCommand)
RegisterCommands register an array of commands to a discord session. Returns a list of all the registered commands.
this function will panic if registration of a command fails.
func RemoveCommands ¶
func RemoveCommands(sess *discordgo.Session, registeredCommands []*discordgo.ApplicationCommand)
RemoveCommands removes all registered slash commands from all servers the bot is in
Types ¶
type Command ¶
type Command struct { // // Name of the slash command // Name string // Command definition ApplicationCommand func() *discordgo.ApplicationCommand // Handler for handling slash command interactions. This function should edit an interaction response. Returns a log message, and error if any EditInteractionResponse HandlerFunc // Handler for handling slash command interactions. This function should send a direct interaction response. Returns a log message, and error if any InteractionRespond HandlerFunc // Handler for auto completion requests. Returns a log message, and error if any InteractionApplicationCommandAutocomplete HandlerFunc // Command components, with their handler Components []struct { // Custom component ID ComponentID string // Handler for component interactions ComponentHandler HandlerFunc } }
type HandlerFunc ¶
type HandlerFunc func(sess *discordgo.Session, i *discordgo.InteractionCreate) (successMsg string, err error)
A handler function type for slash commands
Click to show internal directories.
Click to hide internal directories.