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 ButtonComponentHandler
- 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 EntryPointCommandHandler
- type ErrorHandler
- type Handler
- type InteractionEvent
- func (e *InteractionEvent) AutocompleteResult(choices []discord.AutocompleteChoice, opts ...rest.RequestOpt) error
- func (e *InteractionEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *InteractionEvent) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) error
- func (e *InteractionEvent) DeferCreateMessage(ephemeral bool, opts ...rest.RequestOpt) error
- func (e *InteractionEvent) DeferUpdateMessage(opts ...rest.RequestOpt) error
- func (e *InteractionEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
- func (e *InteractionEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
- func (e *InteractionEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *InteractionEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *InteractionEvent) LaunchActivity(opts ...rest.RequestOpt) error
- func (e *InteractionEvent) Modal(modalCreate discord.ModalCreate, opts ...rest.RequestOpt) error
- func (e *InteractionEvent) PremiumRequired(opts ...rest.RequestOpt) errordeprecated
- func (e *InteractionEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, ...) (*discord.Message, error)
- func (e *InteractionEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
- func (e *InteractionEvent) UpdateMessage(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) error
- type InteractionHandler
- type MessageCommandHandler
- 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) ButtonComponent(pattern string, h ButtonComponentHandler)
- func (r *Mux) Command(pattern string, h CommandHandler)
- func (r *Mux) Component(pattern string, h ComponentHandler)
- func (r *Mux) DefaultContext(ctx func() context.Context)
- func (r *Mux) EntryPointCommand(pattern string, h EntryPointCommandHandler)
- func (r *Mux) Error(h ErrorHandler)
- func (r *Mux) Group(fn func(router Router))
- func (r *Mux) Handle(path string, event *InteractionEvent) error
- func (r *Mux) Interaction(pattern string, h InteractionHandler)
- func (r *Mux) Match(path string, t discord.InteractionType, t2 int) bool
- func (r *Mux) MessageCommand(pattern string, h MessageCommandHandler)
- 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) SelectMenuComponent(pattern string, h SelectMenuComponentHandler)
- func (r *Mux) SlashCommand(pattern string, h SlashCommandHandler)
- func (r *Mux) Use(middlewares ...Middleware)
- func (r *Mux) UserCommand(pattern string, h UserCommandHandler)
- func (r *Mux) With(middlewares ...Middleware) Router
- type NotFoundHandler
- type Route
- type Router
- type SelectMenuComponentHandler
- type SlashCommandHandler
- type UserCommandHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SyncCommands ¶ added in v0.15.2
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 Vars map[string]string Ctx context.Context }
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 ButtonComponentHandler ¶ added in v0.18.0
type ButtonComponentHandler func(data discord.ButtonInteractionData, e *ComponentEvent) error
type CommandEvent ¶
type CommandEvent struct { *events.ApplicationCommandInteractionCreate Vars map[string]string Ctx context.Context }
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 Vars map[string]string Ctx context.Context }
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 EntryPointCommandHandler ¶ added in v0.18.11
type EntryPointCommandHandler func(data discord.EntryPointCommandInteractionData, e *CommandEvent) error
type ErrorHandler ¶ added in v0.16.9
type ErrorHandler func(e *InteractionEvent, err error)
type Handler ¶
type Handler func(e *InteractionEvent) error
type InteractionEvent ¶ added in v0.18.0
type InteractionEvent struct { *events.InteractionCreate Vars map[string]string Ctx context.Context }
func (*InteractionEvent) AutocompleteResult ¶ added in v0.18.0
func (e *InteractionEvent) AutocompleteResult(choices []discord.AutocompleteChoice, opts ...rest.RequestOpt) error
func (*InteractionEvent) CreateFollowupMessage ¶ added in v0.18.0
func (e *InteractionEvent) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*InteractionEvent) CreateMessage ¶ added in v0.18.0
func (e *InteractionEvent) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) error
CreateMessage responds to the interaction with a new message.
func (*InteractionEvent) DeferCreateMessage ¶ added in v0.18.0
func (e *InteractionEvent) DeferCreateMessage(ephemeral bool, opts ...rest.RequestOpt) error
DeferCreateMessage responds to the interaction with a "bot is thinking..." message which should be edited later.
func (*InteractionEvent) DeferUpdateMessage ¶ added in v0.18.0
func (e *InteractionEvent) DeferUpdateMessage(opts ...rest.RequestOpt) error
DeferUpdateMessage responds to the interaction with nothing.
func (*InteractionEvent) DeleteFollowupMessage ¶ added in v0.18.0
func (e *InteractionEvent) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
func (*InteractionEvent) DeleteInteractionResponse ¶ added in v0.18.0
func (e *InteractionEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error
func (*InteractionEvent) GetFollowupMessage ¶ added in v0.18.0
func (e *InteractionEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
func (*InteractionEvent) GetInteractionResponse ¶ added in v0.18.0
func (e *InteractionEvent) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)
func (*InteractionEvent) LaunchActivity ¶ added in v0.18.11
func (e *InteractionEvent) LaunchActivity(opts ...rest.RequestOpt) error
LaunchActivity responds to the interaction by launching activity associated with the app.
func (*InteractionEvent) Modal ¶ added in v0.18.0
func (e *InteractionEvent) Modal(modalCreate discord.ModalCreate, opts ...rest.RequestOpt) error
Modal responds to the interaction with a new modal.
func (*InteractionEvent) PremiumRequired
deprecated
added in
v0.18.0
func (e *InteractionEvent) PremiumRequired(opts ...rest.RequestOpt) error
Deprecated: Respond with a discord.ButtonStylePremium button instead. PremiumRequired responds to the interaction with an upgrade button if available.
func (*InteractionEvent) UpdateFollowupMessage ¶ added in v0.18.0
func (e *InteractionEvent) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*InteractionEvent) UpdateInteractionResponse ¶ added in v0.18.0
func (e *InteractionEvent) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
func (*InteractionEvent) UpdateMessage ¶ added in v0.18.0
func (e *InteractionEvent) UpdateMessage(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) error
UpdateMessage responds to the interaction with updating the message the component is from.
type InteractionHandler ¶ added in v0.18.0
type InteractionHandler func(e *InteractionEvent) error
type MessageCommandHandler ¶ added in v0.18.0
type MessageCommandHandler func(data discord.MessageCommandInteractionData, e *CommandEvent) error
type Middleware ¶
type Middlewares ¶
type Middlewares []Middleware
type ModalEvent ¶
type ModalEvent struct { *events.ModalSubmitInteractionCreate Vars map[string]string Ctx context.Context }
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 ¶ added in v0.15.1
type Mux struct {
// contains filtered or unexported fields
}
Mux is a basic Router implementation.
func (*Mux) Autocomplete ¶ added in v0.15.1
func (r *Mux) Autocomplete(pattern string, h AutocompleteHandler)
Autocomplete registers the given AutocompleteHandler to the current Router.
func (*Mux) ButtonComponent ¶ added in v0.18.0
func (r *Mux) ButtonComponent(pattern string, h ButtonComponentHandler)
ButtonComponent registers the given ButtonComponentHandler to the current Router.
func (*Mux) Command ¶ added in v0.15.1
func (r *Mux) Command(pattern string, h CommandHandler)
Command registers the given CommandHandler to the current Router.
func (*Mux) Component ¶ added in v0.15.1
func (r *Mux) Component(pattern string, h ComponentHandler)
Component registers the given ComponentHandler to the current Router.
func (*Mux) DefaultContext ¶ added in v0.18.0
DefaultContext sets the default context for this router. This context will be used for all interaction events.
func (*Mux) EntryPointCommand ¶ added in v0.18.11
func (r *Mux) EntryPointCommand(pattern string, h EntryPointCommandHandler)
EntryPointCommand registers the given EntryPointCommandHandler to the current Router.
func (*Mux) Error ¶ added in v0.16.9
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) Handle ¶ added in v0.15.1
func (r *Mux) Handle(path string, event *InteractionEvent) error
Handle handles the given interaction event.
func (*Mux) Interaction ¶ added in v0.18.0
func (r *Mux) Interaction(pattern string, h InteractionHandler)
Interaction registers the given InteractionHandler to the current Router. This is a shortcut for Command, Autocomplete, Component and Modal.
func (*Mux) MessageCommand ¶ added in v0.18.0
func (r *Mux) MessageCommand(pattern string, h MessageCommandHandler)
MessageCommand registers the given MessageCommandHandler to the current Router.
func (*Mux) Modal ¶ added in v0.15.1
func (r *Mux) Modal(pattern string, h ModalHandler)
Modal registers the given ModalHandler to the current Router.
func (*Mux) Mount ¶ added in v0.15.1
Mount mounts the given router with the given pattern to the current Router.
func (*Mux) NotFound ¶ added in v0.15.1
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 ¶ added in v0.15.1
Route creates a new sub-router with the given pattern and adds it to the current Router.
func (*Mux) SelectMenuComponent ¶ added in v0.18.0
func (r *Mux) SelectMenuComponent(pattern string, h SelectMenuComponentHandler)
SelectMenuComponent registers the given SelectMenuComponentHandler to the current Router.
func (*Mux) SlashCommand ¶ added in v0.18.0
func (r *Mux) SlashCommand(pattern string, h SlashCommandHandler)
SlashCommand registers the given SlashCommandHandler to the current Router.
func (*Mux) Use ¶ added in v0.15.1
func (r *Mux) Use(middlewares ...Middleware)
Use adds the given middlewares to the current Router.
func (*Mux) UserCommand ¶ added in v0.18.0
func (r *Mux) UserCommand(pattern string, h UserCommandHandler)
UserCommand registers the given UserCommandHandler to the current Router.
func (*Mux) With ¶ added in v0.15.1
func (r *Mux) With(middlewares ...Middleware) Router
With returns a new Router with the given middlewares.
type NotFoundHandler ¶ added in v0.15.1
type NotFoundHandler func(e *InteractionEvent) error
type Route ¶
type Route interface { // Match returns true if the given path matches the Route. Match(path string, t discord.InteractionType, t2 int) bool // Handle handles the given interaction event. Handle(path string, e *InteractionEvent) 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) // Interaction registers the given InteractionHandler to the current Router. Interaction(pattern string, h InteractionHandler) // Command registers the given CommandHandler to the current Router. Command(pattern string, h CommandHandler) // SlashCommand registers the given SlashCommandHandler to the current Router. SlashCommand(pattern string, h SlashCommandHandler) // UserCommand registers the given UserCommandHandler to the current Router. UserCommand(pattern string, h UserCommandHandler) // MessageCommand registers the given MessageCommandHandler to the current Router. MessageCommand(pattern string, h MessageCommandHandler) // EntryPointCommand registers the given EntryPointCommandHandler to the current Router. EntryPointCommand(pattern string, h EntryPointCommandHandler) // 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) // ButtonComponent registers the given ButtonComponentHandler to the current Router. ButtonComponent(pattern string, h ButtonComponentHandler) // SelectMenuComponent registers the given SelectMenuComponentHandler to the current Router. SelectMenuComponent(pattern string, h SelectMenuComponentHandler) // 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.
type SelectMenuComponentHandler ¶ added in v0.18.0
type SelectMenuComponentHandler func(data discord.SelectMenuInteractionData, e *ComponentEvent) error
type SlashCommandHandler ¶ added in v0.18.0
type SlashCommandHandler func(data discord.SlashCommandInteractionData, e *CommandEvent) error
type UserCommandHandler ¶ added in v0.18.0
type UserCommandHandler func(data discord.UserCommandInteractionData, e *CommandEvent) error