bot

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Session *discordgo.Session
	Cfg     *config.Config
	Repo    repository.Repository
	Svc     service.Service
	Cron    *cron.Cron
}

func New

func New() *Bot

func (*Bot) Close

func (b *Bot) Close()

func (*Bot) Run

func (b *Bot) Run()

type Command

type Command interface {
	// Invokes returns a list of strings that can be used to invoke the command, all of which are case-insensitive.
	Invokes() []string
	// Description returns a short description of the command.
	Description() string
	// Exec executes the command.
	Exec(ctx *Context) error
	// Is required admin permission to execute the command.
	IsAdminRequired() bool
}

type CommandHandler

type CommandHandler struct {
	OnError func(ctx *Context, err error)
	// contains filtered or unexported fields
}

func NewCommandHandler

func NewCommandHandler(prefix string) *CommandHandler

NewCommandHandler creates a new CommandHandler.

func (*CommandHandler) GetCommands

func (c *CommandHandler) GetCommands() []Command

func (*CommandHandler) HandleMessage

func (c *CommandHandler) HandleMessage(s *discordgo.Session, e *discordgo.MessageCreate)

func (*CommandHandler) RegisterCommand

func (c *CommandHandler) RegisterCommand(cmd Command)

func (*CommandHandler) RegisterMiddleware

func (c *CommandHandler) RegisterMiddleware(mw Middleware)

type Context

type Context struct {
	Session  *discordgo.Session
	Message  *discordgo.Message
	Args     []string
	Handler  *CommandHandler
	Commands []Command
}

type Middleware

type Middleware interface {
	Exec(ctx *Context, cmd Command) (next bool, err error)
}

Jump to

Keyboard shortcuts

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