middleware

command
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

README

example: middleware

middleware is a basic Discord bot that has a several middlewares defined, along with a simple command containing the aliases ?p, ?priv, and ?privileged. The command is explicitly disallowed from being invoked in a private DM channel thanks to the Filter middleware and Sayori's Filter package.

The Validate middleware will be run after Filter and will determine whether the user calling it has admin privileges.

These middlewares are executed in the order they are added to the route. In the following two examples, the Filter middleware will always be run before Validate.

router.Has(
    v2.NewRoute(&Prefix{}).
        On("p", "priv", "privileged").
        Do(&Privilege{}).
        Use(&Filter{}, &Validate{}),
)
router.Has(
    v2.NewRoute(&Prefix{}).
        On("p", "priv", "privileged").
        Do(&Privilege{}).
        Use(&Filter{}).Use(&Validate{}),
)

run

go build

./middleware -t <discord bot token>

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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