botbuilder

package module
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 4 Imported by: 0

README

botbuilder

CI issues forks stars license Go Go Reference Go Report Card

An extension for discordgo to create a Discord bot quickly using the Builder pattern.

Examples here

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

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.

func (BotData) Build added in v0.3.5

func (b BotData) Build() (*discordgo.Session, error)

Builds the Discord session.

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
}

type Subcommand added in v0.2.0

type Subcommand struct {
	Name           string
	Description    string
	Aliases        []string
	ExecuteCommand bool
	Execute        func(*discordgo.Session, *discordgo.MessageCreate, []string)
}

Subcommand represents a Discord subcommand.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL