Documentation
¶
Overview ¶
Package botbuilder allows for simple Discord bot initialization utilizing the builder pattern. The Discord API functionality is provided by a well-known package discorsessiono.
Index ¶
- type BotBuilder
- func (bb *BotBuilder) AddCommand(command Command) *BotBuilder
- func (bb *BotBuilder) AddCommands(commands ...Command) *BotBuilder
- func (bb *BotBuilder) AddEventHandler(eventHandler func(*discordgo.Session, interface{})) *BotBuilder
- func (bb *BotBuilder) AddEventHandlers(eventHandlers ...func(*discordgo.Session, interface{})) *BotBuilder
- func (bb *BotBuilder) AddSlashCommand(slashCommand *SlashCommand) *BotBuilder
- func (bb *BotBuilder) AddSlashCommands(slashCommands ...*SlashCommand) *BotBuilder
- func (bb *BotBuilder) Build() (*discordgo.Session, error)
- func (bb *BotBuilder) SetIntents(intents discordgo.Intent) *BotBuilder
- func (bb *BotBuilder) SetMessageCollector(collector []*discordgo.MessageCreate) *BotBuilder
- func (bb *BotBuilder) SetPrefix(prefix string) *BotBuilder
- type BotData
- type Command
- type SlashCommand
- type Subcommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotBuilder ¶
type BotBuilder struct {
// contains filtered or unexported fields
}
BotBuilder represents a Discord bot builder.
func NewBotBuilder ¶
func NewBotBuilder(token string) *BotBuilder
NewBotBuilder creates a new BotBuilder object and writes the token specified into the builder. You don't have to add "Bot " to the token like in discorsessiono as the builder will do it for you.
func (*BotBuilder) AddCommand ¶ added in v0.2.0
func (bb *BotBuilder) AddCommand(command Command) *BotBuilder
AddCommand adds a single command to the bot.
func (*BotBuilder) AddCommands ¶ added in v0.2.0
func (bb *BotBuilder) AddCommands(commands ...Command) *BotBuilder
AddCommands adds multiple commands to the bot.
func (*BotBuilder) AddEventHandler ¶
func (bb *BotBuilder) AddEventHandler(eventHandler func(*discordgo.Session, interface{})) *BotBuilder
AddEventHandler adds a single Discord event handler to the bot.
func (*BotBuilder) AddEventHandlers ¶
func (bb *BotBuilder) AddEventHandlers(eventHandlers ...func(*discordgo.Session, interface{})) *BotBuilder
AddEventHandlers adds multiple Discord event handlers to the bot.
func (*BotBuilder) AddSlashCommand ¶ added in v0.3.5
func (bb *BotBuilder) AddSlashCommand(slashCommand *SlashCommand) *BotBuilder
AddSlashCommand adds a single slash command to the bot.
func (*BotBuilder) AddSlashCommands ¶ added in v0.3.5
func (bb *BotBuilder) AddSlashCommands(slashCommands ...*SlashCommand) *BotBuilder
AddSlashCommands adds multiple slash commands to the bot.
func (*BotBuilder) Build ¶
func (bb *BotBuilder) Build() (*discordgo.Session, error)
Build creates a Discord bot, adding the command handler and event handlers specified.
func (*BotBuilder) SetIntents ¶ added in v0.1.2
func (bb *BotBuilder) SetIntents(intents discordgo.Intent) *BotBuilder
SetIntents sets the bot's intents. If not called, the bot's intents will be set to IntentsGuildMessages.
func (*BotBuilder) SetMessageCollector ¶ added in v0.2.0
func (bb *BotBuilder) SetMessageCollector(collector []*discordgo.MessageCreate) *BotBuilder
SetMessageBuffer sets a message collector for the bot. Every time a MessageCreate event is invoked the event data is passed into c.
func (*BotBuilder) SetPrefix ¶ added in v0.3.0
func (bb *BotBuilder) SetPrefix(prefix string) *BotBuilder
SetPrefix sets a prefix for the bot. By default, there is no prefix.
type BotData ¶ added in v0.3.5
type BotData struct { Token string Prefix string Commands []Command Intents discordgo.Intent EventHandlers []func(*discordgo.Session, interface{}) MessageCollector []*discordgo.MessageCreate }
BotData represents Discord bot data and provides another way of using botbuilder. Default intents are IntentsGuildMessages.
type Command ¶ added in v0.2.0
type Command struct { Name string Description string Aliases []string Subcommands []Subcommand Execute func(*discordgo.Session, *discordgo.MessageCreate, []string) }
Command represents a Discord command.
type SlashCommand ¶ added in v0.3.5
type SlashCommand struct { ApplicationCommand *discordgo.ApplicationCommand Execute func(session *discordgo.Session, event *discordgo.InteractionCreate) Guild string }