middleware

package
v2.0.0-...-6a7c878 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelNotNSFW = errors.New("this command can only be used in an NSFW channel")
	ErrChannelType    = errors.New("channel type does not match expected type")
)

Errors

Functions

func CatchReply

func CatchReply(message string) func(ctx *astral.Context)

CatchReply returns a function that prints the message you pass it

func ChannelType

func ChannelType(t discord.ChannelType, catch CatchFunc) astral.MiddlewareFunc

ChannelType requires the specific channel type from the message

func Permission

func Permission(permission discord.Permissions) astral.MiddlewareFunc

Permission validates the permission level

func Recoverer

func Recoverer(rec RecoverFunc) astral.MiddlewareFunc

Recoverer is a middleware to catch panics inside calls. Usually, this is best to handle to make sure your code is working right, HOWEVER this is useful to catch errors and log them instead of fatally erroring.

func RequireNSFW

func RequireNSFW(catch CatchFunc) astral.MiddlewareFunc

RequireNSFW requires a message to be sent from an NSFW channel

Types

type CatchFunc

type CatchFunc func(ctx *astral.Context)

CatchFunc function called if one of the middleware experiences an error Can be left as nil

type RecoverFunc

type RecoverFunc func(ctx *astral.Context, v interface{})

RecoverFunc is a function called if a handler is recovered

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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