bot

package
v21.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateCommand = errors.New("duplicate command")

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

	UseSlashCommands    bool
	GlobalSlashCommands []jsonapi.ApplicationCommand
	GuildSlashCommands  map[snowflake.Snowflake][]jsonapi.ApplicationCommand
}

Config is the set of configuration options for creating a DiscordBot with NewDiscordBot

type DiscordBot

type DiscordBot struct {
	// contains filtered or unexported fields
}

func NewDiscordBot

func NewDiscordBot(deps dependencies, conf Config, permissions, intents int) *DiscordBot

NewDiscordBot creates a new DiscordBot

func (*DiscordBot) API

func (*DiscordBot) AuthenticateAndConnect

func (d *DiscordBot) AuthenticateAndConnect() error

func (*DiscordBot) Config

func (d *DiscordBot) Config() Config

func (*DiscordBot) DiffAndRegisterSlashCommands

func (d *DiscordBot) DiffAndRegisterSlashCommands(ctx context.Context) error

func (*DiscordBot) Disconnect

func (d *DiscordBot) Disconnect() error

func (*DiscordBot) Dispatcher

func (d *DiscordBot) Dispatcher() Dispatcher

func (*DiscordBot) Intents

func (d *DiscordBot) Intents() int

func (*DiscordBot) LastSequence

func (d *DiscordBot) LastSequence() int

func (*DiscordBot) ReconfigureHeartbeat

func (d *DiscordBot) ReconfigureHeartbeat(ctx context.Context, interval int)

func (*DiscordBot) Run

func (d *DiscordBot) Run(ctx context.Context) error

func (*DiscordBot) SetDebug

func (d *DiscordBot) SetDebug(val bool)

func (*DiscordBot) UpdateSequence

func (d *DiscordBot) UpdateSequence(seq int) bool

type DispatchHandlerFunc

type DispatchHandlerFunc = func(Payload, wsapi.WSMessage, chan<- wsapi.WSMessage) snowflake.Snowflake

DispatcherFunc 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

type Logger

type Logger = interface {
	Log(keyvals ...interface{}) error
	Message(string, ...interface{})
	Err(string, error, ...interface{})
	Printf(string, ...interface{})
}

type Payload

type Payload = interface {
	EventName() string
	Contents() map[string]etfapi.Element
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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