Documentation
¶
Index ¶
- func SyncCommands(client bot.Client, commands []discord.ApplicationCommandCreate, ...) error
- type AutocompleteEvent
- func (e *AutocompleteEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *AutocompleteEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
- func (e *AutocompleteEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *AutocompleteEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, ...) (*discord.Message, error)
- type AutocompleteHandler
- type CommandEvent
- func (e *CommandEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *CommandEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
- func (e *CommandEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
- func (e *CommandEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *CommandEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *CommandEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, ...) (*discord.Message, error)
- func (e *CommandEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
- type CommandHandler
- type ComponentEvent
- func (e *ComponentEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ComponentEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
- func (e *ComponentEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
- func (e *ComponentEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ComponentEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ComponentEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, ...) (*discord.Message, error)
- func (e *ComponentEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
- type ComponentHandler
- type ErrorHandler
- type Handler
- type Middleware
- type Middlewares
- type ModalEvent
- func (e *ModalEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ModalEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
- func (e *ModalEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
- func (e *ModalEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ModalEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *ModalEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, ...) (*discord.Message, error)
- func (e *ModalEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
- type ModalHandler
- type Mux
- func (r *Mux) Autocomplete(pattern string, h AutocompleteHandler)
- func (r *Mux) Command(pattern string, h CommandHandler)
- func (r *Mux) Component(pattern string, h ComponentHandler)
- func (r *Mux) Error(h ErrorHandler)
- func (r *Mux) Group(fn func(router Router))
- func (r *Mux) Handle(path string, variables map[string]string, e *events.InteractionCreate) error
- func (r *Mux) Match(path string, t discord.InteractionType) bool
- func (r *Mux) Modal(pattern string, h ModalHandler)
- func (r *Mux) Mount(pattern string, router Router)
- func (r *Mux) NotFound(h NotFoundHandler)
- func (r *Mux) OnEvent(event bot.Event)
- func (r *Mux) Route(pattern string, fn func(r Router)) Router
- func (r *Mux) Use(middlewares ...Middleware)
- func (r *Mux) With(middlewares ...Middleware) Router
- type NotFoundHandler
- type Route
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SyncCommands ¶
func SyncCommands(client bot.Client, commands []discord.ApplicationCommandCreate, guildIDs []snowflake.ID, opts ...rest.RequestOpt) error
SyncCommands sets the given commands for the given guilds or globally if no guildIDs are empty. It will return on the first error for multiple guilds.
Types ¶
type AutocompleteEvent ¶
type AutocompleteEvent struct { *events.AutocompleteInteractionCreate Variables map[string]string }
func (*AutocompleteEvent) CreateFollowupMessage ¶
func (e *AutocompleteEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*AutocompleteEvent) DeleteFollowupMessage ¶
func (e *AutocompleteEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
func (*AutocompleteEvent) GetFollowupMessage ¶
func (e *AutocompleteEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
func (*AutocompleteEvent) UpdateFollowupMessage ¶
func (e *AutocompleteEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
type AutocompleteHandler ¶
type AutocompleteHandler func(e *AutocompleteEvent) error
type CommandEvent ¶
type CommandEvent struct { *events.ApplicationCommandInteractionCreate Variables map[string]string }
func (*CommandEvent) CreateFollowupMessage ¶
func (e *CommandEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*CommandEvent) DeleteFollowupMessage ¶
func (e *CommandEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
func (*CommandEvent) DeleteInteractionResponse ¶
func (e *CommandEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
func (*CommandEvent) GetFollowupMessage ¶
func (e *CommandEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
func (*CommandEvent) GetInteractionResponse ¶
func (e *CommandEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
func (*CommandEvent) UpdateFollowupMessage ¶
func (e *CommandEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*CommandEvent) UpdateInteractionResponse ¶
func (e *CommandEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
type CommandHandler ¶
type CommandHandler func(e *CommandEvent) error
type ComponentEvent ¶
type ComponentEvent struct { *events.ComponentInteractionCreate Variables map[string]string }
func (*ComponentEvent) CreateFollowupMessage ¶
func (e *ComponentEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ComponentEvent) DeleteFollowupMessage ¶
func (e *ComponentEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
func (*ComponentEvent) DeleteInteractionResponse ¶
func (e *ComponentEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
func (*ComponentEvent) GetFollowupMessage ¶
func (e *ComponentEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ComponentEvent) GetInteractionResponse ¶
func (e *ComponentEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
func (*ComponentEvent) UpdateFollowupMessage ¶
func (e *ComponentEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ComponentEvent) UpdateInteractionResponse ¶
func (e *ComponentEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
type ComponentHandler ¶
type ComponentHandler func(e *ComponentEvent) error
type ErrorHandler ¶ added in v0.5.1
type ErrorHandler func(e *events.InteractionCreate, err error)
type Handler ¶
type Handler func(e *events.InteractionCreate) error
type Middleware ¶
type Middlewares ¶
type Middlewares []Middleware
type ModalEvent ¶
type ModalEvent struct { *events.ModalSubmitInteractionCreate Variables map[string]string }
func (*ModalEvent) CreateFollowupMessage ¶
func (e *ModalEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ModalEvent) DeleteFollowupMessage ¶
func (e *ModalEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
func (*ModalEvent) DeleteInteractionResponse ¶
func (e *ModalEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
func (*ModalEvent) GetFollowupMessage ¶
func (e *ModalEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ModalEvent) GetInteractionResponse ¶
func (e *ModalEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
func (*ModalEvent) UpdateFollowupMessage ¶
func (e *ModalEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*ModalEvent) UpdateInteractionResponse ¶
func (e *ModalEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
type ModalHandler ¶
type ModalHandler func(e *ModalEvent) error
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is a basic Router implementation.
func (*Mux) Autocomplete ¶
func (r *Mux) Autocomplete(pattern string, h AutocompleteHandler)
Autocomplete registers the given AutocompleteHandler to the current Router.
func (*Mux) Command ¶
func (r *Mux) Command(pattern string, h CommandHandler)
Command registers the given CommandHandler to the current Router.
func (*Mux) Component ¶
func (r *Mux) Component(pattern string, h ComponentHandler)
Component registers the given ComponentHandler to the current Router.
func (*Mux) Error ¶ added in v0.5.1
func (r *Mux) Error(h ErrorHandler)
Error sets the ErrorHandler for this router. This handler only works for the root router and will be ignored for sub routers.
func (*Mux) Match ¶
func (r *Mux) Match(path string, t discord.InteractionType) bool
Match returns true if the given path matches the Route.
func (*Mux) Modal ¶
func (r *Mux) Modal(pattern string, h ModalHandler)
Modal registers the given ModalHandler to the current Router.
func (*Mux) NotFound ¶
func (r *Mux) NotFound(h NotFoundHandler)
NotFound sets the NotFoundHandler for this router. This handler only works for the root router and will be ignored for sub routers.
func (*Mux) Route ¶
Route creates a new sub-router with the given pattern and adds it to the current Router.
func (*Mux) Use ¶
func (r *Mux) Use(middlewares ...Middleware)
Use adds the given middlewares to the current Router.
func (*Mux) With ¶
func (r *Mux) With(middlewares ...Middleware) Router
With returns a new Router with the given middlewares.
type NotFoundHandler ¶
type NotFoundHandler func(e *events.InteractionCreate) error
type Route ¶
type Route interface { // Match returns true if the given path matches the Route. Match(path string, t discord.InteractionType) bool // Handle handles the given interaction event. Handle(path string, variables map[string]string, e *events.InteractionCreate) error }
Route is a basic interface for a route in a Router.
type Router ¶
type Router interface { bot.EventListener Route // Use adds the given middlewares to the current Router. Use(middlewares ...Middleware) // With returns a new Router with the given middlewares. With(middlewares ...Middleware) Router // Group creates a new Router and adds it to the current Router. Group(fn func(r Router)) // Route creates a new sub-router with the given pattern and adds it to the current Router. Route(pattern string, fn func(r Router)) Router // Mount mounts the given router with the given pattern to the current Router. Mount(pattern string, r Router) // Command registers the given CommandHandler to the current Router. Command(pattern string, h CommandHandler) // Autocomplete registers the given AutocompleteHandler to the current Router. Autocomplete(pattern string, h AutocompleteHandler) // Component registers the given ComponentHandler to the current Router. Component(pattern string, h ComponentHandler) // Modal registers the given ModalHandler to the current Router. Modal(pattern string, h ModalHandler) }
Router provides with the core routing functionality. It is used to register handlers and middlewares and sub-routers.