bot

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 6 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 {
	*discord.Session

	Router *Router
}

func NewBot

func NewBot(token string) (*Bot, error)

func (*Bot) Run

func (b *Bot) Run(guildID string, removeCommands bool)

type Command added in v0.4.1

type Command struct {
	Name                     string
	Description              string
	DMPermission             bool
	DefaultMemberPermissions int64
	Options                  []*discord.ApplicationCommandOption
	Type                     discord.ApplicationCommandType

	Handler        Handler
	Middlewares    []Handler
	MessageHandler MessageHandler

	SubCommands *Router
}

func (Command) ApplicationCommand added in v0.4.1

func (cmd Command) ApplicationCommand() *discord.ApplicationCommand

func (Command) ApplicationCommandOption added in v0.4.1

func (cmd Command) ApplicationCommandOption() *discord.ApplicationCommandOption

type Context added in v0.4.1

type Context struct {
	*discord.Session
	Caller      *Command
	Interaction *discord.Interaction
	Options     OptionsMap
	// contains filtered or unexported fields
}

func NewContext added in v0.4.1

func (*Context) Edit added in v0.4.1

func (ctx *Context) Edit(content string) error

func (*Context) Next added in v0.4.1

func (ctx *Context) Next()

func (*Context) Respond added in v0.4.1

func (ctx *Context) Respond(response *discord.InteractionResponse) error

func (*Context) Response added in v0.4.1

func (ctx *Context) Response() (*discord.Message, error)

type Handler added in v0.4.1

type Handler interface {
	HandleCommand(ctx *Context)
}

type HandlerFunc added in v0.4.1

type HandlerFunc func(ctx *Context)

func (HandlerFunc) HandleCommand added in v0.4.1

func (f HandlerFunc) HandleCommand(ctx *Context)

type MessageContext added in v0.4.1

type MessageContext struct {
	*discord.Session
	Caller  *Command
	Message *discord.Message
	// contains filtered or unexported fields
}

func NewMessageContext added in v0.4.1

func NewMessageContext(s *discord.Session, caller *Command, m *discord.Message, handlers []MessageHandler) *MessageContext

func (*MessageContext) AddReaction added in v0.4.1

func (ctx *MessageContext) AddReaction(emojiID string) error

func (*MessageContext) ChannelTyping added in v0.4.1

func (ctx *MessageContext) ChannelTyping() error

func (*MessageContext) EmbedReply added in v0.4.1

func (ctx *MessageContext) EmbedReply(embed *discord.MessageEmbed) (m *discord.Message, err error)

func (*MessageContext) Next added in v0.4.1

func (ctx *MessageContext) Next()

func (*MessageContext) RemoveReaction added in v0.4.1

func (ctx *MessageContext) RemoveReaction(emojiID string) error

func (*MessageContext) Reply added in v0.4.1

func (ctx *MessageContext) Reply(content string) (m *discord.Message, err error)

type MessageHandler added in v0.4.1

type MessageHandler interface {
	HandleMessageCommand(ctx *MessageContext)
}

type MessageHandlerFunc added in v0.4.1

type MessageHandlerFunc func(ctx *MessageContext)

func (MessageHandlerFunc) HandleMessageCommand added in v0.4.1

func (f MessageHandlerFunc) HandleMessageCommand(ctx *MessageContext)

type OptionsMap added in v0.4.1

type Router added in v0.2.0

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

func NewRouter added in v0.2.0

func NewRouter(initial []*Command) (r *Router)

func (*Router) ClearCommands added in v0.2.0

func (r *Router) ClearCommands(s *discord.Session, guild string) (errors []error)

func (*Router) Count added in v0.4.1

func (r *Router) Count() (c int)

func (*Router) Get added in v0.4.1

func (r *Router) Get(name string) *Command

func (*Router) HandleInteraction added in v0.2.0

func (r *Router) HandleInteraction(s *discord.Session, i *discord.InteractionCreate)

func (*Router) HandleMessage added in v0.2.0

func (r *Router) HandleMessage(s *discord.Session, m *discord.MessageCreate)

func (*Router) List added in v0.4.1

func (r *Router) List() (list []*Command)

func (*Router) Register added in v0.2.0

func (r *Router) Register(cmd *Command)

func (*Router) Sync added in v0.2.0

func (r *Router) Sync(s *discord.Session, guild string) (err error)

Jump to

Keyboard shortcuts

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