bot

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOptions = errors.New("invalid options")
View Source
var ErrResponseNotSent = errors.New("response not yet sent")

Functions

This section is empty.

Types

type Bot

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

func NewBot

func NewBot(logger *slog.Logger, guildRepo *guilds.GuildRepository) *Bot

func (*Bot) AddCommand

func (b *Bot) AddCommand(data *discordgo.ApplicationCommand, cmd CommandHandler)

func (*Bot) Close

func (b *Bot) Close()

func (*Bot) CollectSingleComponentInteraction added in v0.2.4

func (b *Bot) CollectSingleComponentInteraction(
	ctx context.Context,
	msg *discordgo.Message,
	filters ...discordutil.InteractionFilter,
) (*discordgo.InteractionCreate, error)

func (*Bot) Login

func (b *Bot) Login(token string, intent discordgo.Intent) error

func (*Bot) NewMessageComponentInteractionChannel added in v0.2.4

func (b *Bot) NewMessageComponentInteractionChannel(
	ctx context.Context,
	msg *discordgo.Message,
	filters ...discordutil.InteractionFilter,
) (<-chan *discordgo.InteractionCreate, error)

func (*Bot) SetDestroyCommandsOnClose

func (b *Bot) SetDestroyCommandsOnClose(destroy bool)

func (*Bot) SetNoPanic added in v0.2.2

func (b *Bot) SetNoPanic(noPanic bool)

type Command

type Command struct {
	Handler CommandHandler
	Data    *discordgo.ApplicationCommand
}

type CommandCollection

type CommandCollection map[string]Command

func NewCommandCollection

func NewCommandCollection() CommandCollection

func (CommandCollection) Add

func (CommandCollection) Handle

type CommandHandler

type CommandHandler interface {
	Handle(ctx *InteractionContext) error
}

type InteractionContext

type InteractionContext struct {
	Logger *slog.Logger
	Bot    *Bot
	// contains filtered or unexported fields
}

func NewInteractionContext

func NewInteractionContext(
	logger *slog.Logger,
	bot *Bot,
	s *discordgo.Session,
	i *discordgo.InteractionCreate,
	ctx context.Context,
) *InteractionContext

func (*InteractionContext) CanRespond

func (c *InteractionContext) CanRespond() bool

func (*InteractionContext) Cancel

func (c *InteractionContext) Cancel()

func (*InteractionContext) Context

func (c *InteractionContext) Context() context.Context

Returns a context that is cancelled when the interaction token is invalidated

func (*InteractionContext) Data

func (*InteractionContext) DeferResponse

func (c *InteractionContext) DeferResponse() error

func (*InteractionContext) Deferred

func (c *InteractionContext) Deferred() bool

func (*InteractionContext) EditResponse added in v0.2.4

func (c *InteractionContext) EditResponse(params *discordgo.WebhookEdit) (*discordgo.Message, error)

func (*InteractionContext) Followup

func (c *InteractionContext) Followup(response *discordgo.WebhookParams, wait bool) (*discordgo.Message, error)

func (*InteractionContext) Interaction

func (*InteractionContext) IsAutocomplete

func (c *InteractionContext) IsAutocomplete() bool

func (*InteractionContext) IsCommand

func (c *InteractionContext) IsCommand() bool

func (*InteractionContext) Options

func (*InteractionContext) Respond

func (*InteractionContext) RespondOrFollowup

func (c *InteractionContext) RespondOrFollowup(params *discordgo.WebhookParams, wait bool) (*discordgo.Message, error)

func (*InteractionContext) Responded

func (c *InteractionContext) Responded() bool

func (*InteractionContext) ResponseContext

func (c *InteractionContext) ResponseContext() context.Context

Returns a context that is cancelled when the interaction response deadline is reached or when a response is sent

func (*InteractionContext) Session

func (c *InteractionContext) Session() *discordgo.Session

func (*InteractionContext) User added in v0.2.0

func (c *InteractionContext) User() *discordgo.User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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