Middlewares
Reading time:1 min read
Middlewares are objects or callbacks that run before any subscriber is executed. They can do some pre-processing logic and store it in the metadata, or even prevent the subscriber from being executed.
For general information about middlewares, you must first read the general Middlewares guide.
Usage
Creation
Either:
- Create a class that extends
AbstractEventSubscriberMiddlewareand implements thecheck()method.
import { } from '@nyx-discord/djs';
import type { , , } from '@nyx-discord/djs';
class extends {
public async (
: ,
:
): <> {
// Do some pre-processing logic
return this.();
}
}- Create a function that returns a
MiddlewareResponse.
import { type } from '@nyx-discord/djs';
const : = async (, ) => {
// Do some pre-processing logic
return {
: true,
: true,
};
};Edit on GitHub
Last updated on
