middleware

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Go = GoErr(func(event *handler.InteractionEvent, err error) {
	event.Client().Logger().Error("failed to handle interaction", slog.Any("err", err))
})

Go is a middleware that runs the next handler in a goroutine.

View Source
var Logger handler.Middleware = func(next handler.Handler) handler.Handler {
	return func(event *handler.InteractionEvent) error {
		event.Client().Logger().Info("handling interaction", slog.Int64("interaction_id", int64(event.Interaction.ID())))
		return next(event)
	}
}

Functions

func Defer added in v0.16.8

func Defer(interactionType discord.InteractionType, updateMessage bool, ephemeral bool) handler.Middleware

Defer is a middleware that defers the specified interaction type. If updateMessage is true, it will respond with discord.InteractionResponseTypeDeferredUpdateMessage instead of discord.InteractionResponseTypeDeferredCreateMessage. If ephemeral is true, it will respond with discord.MessageFlagEphemeral flag in case of a discord.InteractionResponseTypeDeferredCreateMessage. Note: You can use this middleware multiple times with different interaction types. Note: You can use this middleware in combination with the Go middleware to defer & run in a goroutine.

func GoDefer added in v0.17.1

func GoDefer(interactionType discord.InteractionType, updateMessage bool, ephemeral bool) handler.Middleware

GoDefer combines Go and Defer

func GoErr added in v0.17.1

GoErr is a middleware that runs the next handler in a goroutine and lets you handle the error which may occur.

func GoErrDefer added in v0.17.1

func GoErrDefer(h handler.ErrorHandler, interactionType discord.InteractionType, updateMessage bool, ephemeral bool) handler.Middleware

GoErrDefer combines GoErr and Defer

func Print

func Print(content string) handler.Middleware

Types

This section is empty.

Jump to

Keyboard shortcuts

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