handler

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 67

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) DeleteInteractionResponse

func (e *AutocompleteEvent) DeleteInteractionResponse(opts ...rest.RequestOpt) error

func (*AutocompleteEvent) GetFollowupMessage

func (e *AutocompleteEvent) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)

func (*AutocompleteEvent) GetInteractionResponse

func (e *AutocompleteEvent) GetInteractionResponse(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)

func (*AutocompleteEvent) UpdateInteractionResponse

func (e *AutocompleteEvent) UpdateInteractionResponse(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 Handler

type Handler func(e *events.InteractionCreate)

type Middleware

type Middleware func(next Handler) Handler

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 added in v0.15.1

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

Mux is a basic Router implementation.

func New

func New() *Mux

New returns a new Router.

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) 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) Group added in v0.15.1

func (r *Mux) Group(fn func(router Router))

Group creates a new Router and adds it to the current Router.

func (*Mux) Handle added in v0.15.1

func (r *Mux) Handle(path string, variables map[string]string, e *events.InteractionCreate) error

Handle handles the given interaction event.

func (*Mux) Match added in v0.15.1

func (r *Mux) Match(path string, t discord.InteractionType) bool

Match returns true if the given path matches the Route.

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

func (r *Mux) Mount(pattern string, router Router)

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) OnEvent added in v0.15.1

func (r *Mux) OnEvent(event bot.Event)

OnEvent is called when a new event is received.

func (*Mux) Route added in v0.15.1

func (r *Mux) Route(pattern string, fn func(r Router)) Router

Route creates a new sub-router with the given pattern and adds it 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) 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(event *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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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