bot

package
v15.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponse = errors.New("error response")

ErrResponse is the error that is wrapped and returned when there is a non-200 api response

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
}

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

type DiscordBot

type DiscordBot interface {
	AuthenticateAndConnect() error
	Disconnect() error
	Run(context.Context) error
	AddMessageHandler(event string, handler DiscordMessageHandlerFunc)
	SendMessage(context.Context, snowflake.Snowflake, JSONMarshaler) (*http.Response, []byte, error)
	GetMessage(context.Context, snowflake.Snowflake, snowflake.Snowflake) (*http.Response, []byte, error)
	CreateReaction(context.Context, snowflake.Snowflake, snowflake.Snowflake, string) (*http.Response, error)
	GetGuildMember(context.Context, snowflake.Snowflake, snowflake.Snowflake) (jsonapi.GuildMemberResponse, error)
	UpdateSequence(int) bool
	ReconfigureHeartbeat(context.Context, int)
	LastSequence() int
	Config() Config
	Intents() int
}

DiscordBot is the api for a discord bot object

func NewDiscordBot

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

NewDiscordBot creates a new DiscordBot

type DiscordMessageHandler

type DiscordMessageHandler interface {
	ConnectToBot(DiscordBot)
	AddHandler(string, DiscordMessageHandlerFunc)
	HandleRequest(wsclient.WSMessage, chan<- wsclient.WSMessage) snowflake.Snowflake
}

DiscordMessageHandler is the api that a bot expects a handler manager to have

type DiscordMessageHandlerFunc

type DiscordMessageHandlerFunc func(*etfapi.Payload, wsclient.WSMessage, chan<- wsclient.WSMessage) snowflake.Snowflake

DiscordMessageHandlerFunc is the api that a bot expects a handler function to have

type JSONMarshaler

type JSONMarshaler interface {
	MarshalJSON() ([]byte, error)
}

JSONMarshaler is the interface implemented by types that can marshal themselves into valid JSON.

Jump to

Keyboard shortcuts

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