Documentation ¶
Overview ¶
Package bot is the high-level constructs around a discord bot
Index ¶
- Variables
- type Config
- type DiscordBot
- func (d *DiscordBot) API() *jsonapi.DiscordJSONClient
- func (d *DiscordBot) AuthenticateAndConnect() error
- func (d *DiscordBot) Config() Config
- func (d *DiscordBot) Disconnect() error
- func (d *DiscordBot) Dispatcher() Dispatcher
- func (d *DiscordBot) Intents() int
- func (d *DiscordBot) LastSequence() int
- func (d *DiscordBot) ReconfigureHeartbeat(ctx context.Context, interval int)
- func (d *DiscordBot) RegisterGlobalCommands(ctx context.Context) error
- func (d *DiscordBot) RegisterGuildCommands(ctx context.Context, gid snowflake.Snowflake, cmds []entity.ApplicationCommand) ([]entity.ApplicationCommand, error)
- func (d *DiscordBot) Run(ctx context.Context) error
- func (d *DiscordBot) SetDebug(val bool)
- func (d *DiscordBot) UpdateSequence(seq int) bool
- type DispatchHandlerFunc
- type Dispatcher
- type Logger
- type Payload
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateCommand = errors.New("duplicate command")
ErrDuplicateCommand represents having multiple commands with the same name
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ClientID string ClientSecret string BotToken string APIURL string NumWorkers int OS string BotName string BotPresence string GlobalSlashCommands []entity.ApplicationCommand }
Config is the set of configuration options for creating a DiscordBot with NewDiscordBot
type DiscordBot ¶
type DiscordBot struct {
// contains filtered or unexported fields
}
DiscordBot is the actal bot
func NewDiscordBot ¶
func NewDiscordBot(deps dependencies, conf Config, permissions, intents int) *DiscordBot
NewDiscordBot creates a new DiscordBot
func (*DiscordBot) API ¶
func (d *DiscordBot) API() *jsonapi.DiscordJSONClient
API returns the DiscordJSONClient
func (*DiscordBot) AuthenticateAndConnect ¶
func (d *DiscordBot) AuthenticateAndConnect() error
AuthenticateAndConnect sets up the bot to run
func (*DiscordBot) Dispatcher ¶
func (d *DiscordBot) Dispatcher() Dispatcher
Dispatcher returns the bot dispatcher
func (*DiscordBot) Intents ¶
func (d *DiscordBot) Intents() int
Intents returns the combined discord intents
func (*DiscordBot) LastSequence ¶
func (d *DiscordBot) LastSequence() int
LastSequence is the last sequence number seen
func (*DiscordBot) ReconfigureHeartbeat ¶
func (d *DiscordBot) ReconfigureHeartbeat(ctx context.Context, interval int)
ReconfigureHeartbeat re-configures the heartbeat ticker
func (*DiscordBot) RegisterGlobalCommands ¶
func (d *DiscordBot) RegisterGlobalCommands(ctx context.Context) error
RegisterGlobalCommands registers the global bot commands with discord
func (*DiscordBot) RegisterGuildCommands ¶
func (d *DiscordBot) RegisterGuildCommands(ctx context.Context, gid snowflake.Snowflake, cmds []entity.ApplicationCommand) ([]entity.ApplicationCommand, error)
RegisterGuildCommands registers the guild-specific commands for a guild with discord
func (*DiscordBot) Run ¶
func (d *DiscordBot) Run(ctx context.Context) error
Run starts handling websocket requests and heartbeats after calling AuthenticateAndConnect
func (*DiscordBot) SetDebug ¶
func (d *DiscordBot) SetDebug(val bool)
SetDebug turns on/off debug mode
func (*DiscordBot) UpdateSequence ¶
func (d *DiscordBot) UpdateSequence(seq int) bool
UpdateSequence updates the sequence number if it is newer
type DispatchHandlerFunc ¶
type DispatchHandlerFunc = func(Payload, wsapi.WSMessage, chan<- wsapi.WSMessage) snowflake.Snowflake
DispatchHandlerFunc is the api that a bot expects a handler function to have
type Dispatcher ¶
type Dispatcher interface { ConnectToBot(*DiscordBot) GenerateHeartbeat(context.Context, int) (wsapi.WSMessage, error) AddHandler(string, DispatchHandlerFunc) HandleRequest(wsapi.WSMessage, chan<- wsapi.WSMessage) snowflake.Snowflake }
Dispatcher is the api that a bot expects a handler manager to have