Documentation ¶
Index ¶
- func SinglePrefixHandler(prefix string) func(*discordgo.Message) string
- type Bot
- func (bot *Bot) GetCommand(commandName string) *Command
- func (bot *Bot) Init()
- func (bot *Bot) ListCommands() []string
- func (bot *Bot) Me() *discordgo.User
- func (bot *Bot) RegisterCommand(cmd *Command)
- func (bot *Bot) RegisterCommands(cmds []*Command)
- func (bot *Bot) RemoveCommand(commandName string)
- type Command
- type Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bot ¶
type Bot struct { // The underlying, preconfigured discordgo session. Session *discordgo.Session // The bot's prefix handler. Prefix func(msg *discordgo.Message) string // The bot's self-description, used in help. Description string // contains filtered or unexported fields }
Bot represents a Discord bot with commands.
func (*Bot) GetCommand ¶
GetCommand gets a command pointer. Returns nil if command does not exist.
func (*Bot) Init ¶
func (bot *Bot) Init()
Init initializes a new Bot instance and registers event handlers.
func (*Bot) ListCommands ¶
ListCommands returns a slice of all command names.
func (*Bot) Me ¶
Me returns the discord bot's own User instance. May return nil before the first READY.
func (*Bot) RegisterCommand ¶
RegisterCommand registers (and overwrites) a command in the bot.
func (*Bot) RegisterCommands ¶
RegisterCommands registers multiple commands at once. This is convenient for, for instance, importing modules created by others.
func (*Bot) RemoveCommand ¶
RemoveCommand removes a command from the bot. If the command does not exist, it does nothing.
type Command ¶
type Command struct { Name string // The lowercase name of the command. Description string // The description to use in help. Category string // A virtual group to use when sorting these commands in a helper. // The checks to run. If you wish to send an error message, do so in the // check itself before returning false. Checks []func(context *Context) bool Runner func(context *Context) // The command runner. }
Command represents a command in a discord bot.
type Context ¶
type Context struct { Bot *Bot // The bot instance. Prefix string // The prefix this command was invoked with. Command *Command // The invoked command. Args []string // The command arguments. Message *discordgo.MessageCreate // The message that triggered this command. Author *discordgo.Member // Shorthand for Message.Author. ChannelID string // Shorthand for Message.ChannelID. GuildID string // Shorthand for Message.GuildID. }
Context provides command context.
func (*Context) Reply ¶
Reply is shorthand to send a message to the channel the command was invoked from.
func (*Context) ReplyWithEmbed ¶
ReplyWithEmbed is shorthand to send a message to the channel the command was invoked from, with an embed.