bot

package
v0.0.0-...-5c9ae66 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App running a bot session

func New

func New() App

New app with default settings

func (App) Session

func (s App) Session() *discordgo.Session

Session returns the underlying session

func (App) Setup

func (s App) Setup(token string) (App, error)

Setup the app by creating a session with the provided token

func (App) Start

func (s App) Start(ctx context.Context) error

Start the underlying session and wait for an Interrupt event to end it

func (App) Stop

func (s App) Stop(ctx context.Context) error

Stop the underlying session

type Command

type Command interface {
	Namer
	Build() *discordgo.ApplicationCommand
	MatchInteraction(id string) bool
	HandleCommand(ctx context.Context, session *discordgo.Session, i *discordgo.InteractionCreate) error
	HandleInteractions(ctx context.Context, session *discordgo.Session, i *discordgo.InteractionCreate) error
}

Command defines the interface for a Discord application

type Guild

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

Guild is a kind of bot that's specific to a Discord guild

func (Guild) Finalize

func (b Guild) Finalize(ctx context.Context, session *discordgo.Session) error

Finalize installs all registered commands and operands into the provided session

func (Guild) WithCommand

func (b Guild) WithCommand(command ...Command) Service

WithCommand returns a Guild with the Command registered

func (Guild) WithOperand

func (b Guild) WithOperand(operands ...Operand) Service

WithOperand returns a Guild with the Operand registered

type Multi

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

Multi is a kind of bot that supports multiple Discord Guilds

func (Multi) Finalize

func (b Multi) Finalize(ctx context.Context, session *discordgo.Session) error

Finalize installs all registered commands and operands into the provided session

func (Multi) WithCommand

func (b Multi) WithCommand(command ...Command) Service

WithCommand returns a Multi with the Command registered

func (Multi) WithOperand

func (b Multi) WithOperand(operands ...Operand) Service

WithOperand returns a Multi with the Operand registered

type Namer

type Namer interface {
	Name() string
}

Namer interface for identifying things

type Operand

type Operand interface {
	Namer
	AddHandlers(ctx context.Context, session *discordgo.Session)
	Intents() discordgo.Intent
}

Operand defines the interface for a default bot component listening for events

type Service

type Service interface {
	WithCommand(command ...Command) Service
	WithOperand(operands ...Operand) Service
	Finalize(ctx context.Context, session *discordgo.Session) error
}

func NewGuild

func NewGuild(appID, guildID string) Service

NewGuild returns a new Guild bot for the specified appID and guildID

func NewMulti

func NewMulti(appID string) Service

NewMulti returns a new Multi bot for the specified appID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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