Documentation ¶
Index ¶
- type AutoCompleter
- type AutoCompleterFunc
- type CommandRoute
- type Context
- type ErrorResponder
- type ErrorResponderFunc
- type Response
- func (r *Response) AddComponents(components ...discordgo.MessageComponent) *Response
- func (r *Response) AddEmbeds(embeds ...*discordgo.MessageEmbed) *Response
- func (r *Response) AddFiles(files ...*discordgo.File) *Response
- func (r *Response) AllowedMentions(allowedMentions *discordgo.MessageAllowedMentions) *Response
- func (r *Response) Components(components ...discordgo.MessageComponent) *Response
- func (r *Response) Content(content string) *Response
- func (r *Response) Embeds(embeds ...*discordgo.MessageEmbed) *Response
- func (r *Response) Files(files ...*discordgo.File) *Response
- func (r *Response) Flags(suppress, ephemeral bool) *Response
- func (r *Response) TTS(tts bool) *Response
- type Router
- type RouterOptions
- type Runner
- type RunnerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoCompleter ¶
type AutoCompleter interface { // AutoComplete returns an array of choices that match the current input of // the Context. The focused option is used to determine which option is // currently focused and, accordingly, the choices should be filtered. AutoComplete(ctx *Context, focused *discordgo.ApplicationCommandInteractionDataOption) []*discordgo.ApplicationCommandOptionChoice }
type AutoCompleterFunc ¶
type AutoCompleterFunc func(ctx *Context, focused *discordgo.ApplicationCommandInteractionDataOption) []*discordgo.ApplicationCommandOptionChoice
AutoCompleterFunc is a function that implements the AutoCompleter interface.
func (AutoCompleterFunc) AutoComplete ¶
func (fn AutoCompleterFunc) AutoComplete(ctx *Context, focused *discordgo.ApplicationCommandInteractionDataOption) []*discordgo.ApplicationCommandOptionChoice
AutoComplete calls fn() itself and returns the result.
type CommandRoute ¶
type CommandRoute struct { // Runner runs the CommandRoute within a given Context. Every CommandRoute must have // at least a Runner. Runner Runner `json:"runner,omitempty"` // AutoCompleter provides auto-completion for the CommandRoute. This is optional. AutoCompleter AutoCompleter `json:"autoCompleter,omitempty"` // ErrorResponder is the command's individual ErrorResponder used to // construct interaction responses from errors. If this is nil, the Router's // ErrorResponder is used. ErrorResponder ErrorResponder `json:"errorResponder,omitempty"` }
type Context ¶
type Context struct { *discordgo.InteractionCreate // Command is the command name that was used to invoke the interaction. Command string // Session is the session that received the interaction-create event. It can // be used to interact directly with Discord. Session *discordgo.Session }
func (*Context) FocusedOption ¶
func (ctx *Context) FocusedOption() *discordgo.ApplicationCommandInteractionDataOption
FocusedOption searches for the first option that is focused and returns it. If no option is found, nil is returned instead.
func (*Context) Option ¶
func (ctx *Context) Option(name string) *discordgo.ApplicationCommandInteractionDataOption
Option searches for the first option that matches the given name and returns it. If no option is found, nil is returned instead
Option names are case-insensitive. Therefore, "option" and "OPTION" are considered the same.
type ErrorResponder ¶
type ErrorResponderFunc ¶
ErrorResponderFunc is a function that implements the ErrorResponder interface.
func (ErrorResponderFunc) RespondError ¶
func (fn ErrorResponderFunc) RespondError(ctx *Context, resp *Response, err error)
RespondError calls fn() itself and returns the result.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) AddComponents ¶
func (r *Response) AddComponents(components ...discordgo.MessageComponent) *Response
AddComponents adds the given components to the response message.
func (*Response) AddEmbeds ¶
func (r *Response) AddEmbeds(embeds ...*discordgo.MessageEmbed) *Response
AddEmbeds adds the given embeds to the response message.
func (*Response) AllowedMentions ¶
func (r *Response) AllowedMentions(allowedMentions *discordgo.MessageAllowedMentions) *Response
AllowedMentions updates the allowed mentions of the response message.
func (*Response) Components ¶
func (r *Response) Components(components ...discordgo.MessageComponent) *Response
Components updates the components of the response message.
func (*Response) Embeds ¶
func (r *Response) Embeds(embeds ...*discordgo.MessageEmbed) *Response
Embeds updates the embeds of the response message.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(opts *RouterOptions) *Router
NewRouter returns a new router without any commands. The given options are used to change the behavior of the router. If nil is passed, the default options are used.
func (*Router) AutoBind ¶
AutoBind binds the given CommandRoute to the given name. If the name is already taken, the existing CommandRoute is overwritten.
The difference between Bind and AutoBind is that AutoBind takes a Runner and
tests whether the Runner is also an AutoCompleter. If that is the case,
the AutoCompleter is bound to the CommandRoute.
CommandRoute names are case-insensitive. Therefore, "command" and "COMMAND" are considered the same. Note that the name is stored in the lower-case.
func (*Router) AutoBindAll ¶
AutoBindAll binds all commands in the given map to the Router using its AutoBind() method. For more details, see AutoBind().
func (*Router) Bind ¶
func (r *Router) Bind(name string, cmd *CommandRoute)
Bind binds the given CommandRoute to the given name. If the name is already taken, the existing CommandRoute is overwritten.
CommandRoute names are case-insensitive. Therefore, "command" and "COMMAND" are considered the same. Note that the name is stored in the lower-case.
func (*Router) BindAll ¶
func (r *Router) BindAll(cmds map[string]*CommandRoute)
BindAll binds all commands in the given map to the Router using its Bind() method. For more details, see Bind().
type RouterOptions ¶
type RouterOptions struct { // ErrorResponder is the ErrorResponder that is used to construct error // responses. ErrorResponder ErrorResponder }
type Runner ¶
type Runner interface { // Run executes the CommandRoute with the given context. If the CommandRoute fails, // the causing error is returned. // // The given Response is used to mutate the response message. The response // message is built after the CommandRoute is run successfully. Run(ctx *Context, resp *Response) error }