Creators
Main base structures for creating commands and systems
On this base, to create commands and systems you must use the creator functions, which are createCommand
, createEvent
and createResponder
.
When executing these functions passing the data of the respective structures, they will be created and registered.
You can set some options in the index
file of the discord
folder, see:
This function receives options and returns the creators of commands, events and responders for you to use. By exporting this return you can import them at any time using the base import alias:
Command Options
You can set some command options in the setupCreators
function:
Set what the default permissions will be for all commands, if none are defined with the defaultMemberPermissions
option (It is the same permissions array as the command).
This way, when you create a command and do not set any default member permissions, what you set in the setupCreators
function will be the default for all commands.
Responder Options
You can set some responder options in the setupCreators
function:
You can set a middleware
function that will be executed before the responders` run function
Just like with commands, you can do a lot with this, such as displaying standardized logs for all executed responders, injecting additional information into the interaction, or even blocking execution based on checks.
You can run the block
function to block responders from executing.
Event options
You can set some event options in the setupCreators
function:
You can set a middleware
function that will be executed before the events run
function
As with commands and responders, you can do a lot with this, such as displaying standardized logs for all executed events, injecting additional information into the arguments of specific events, or even blocking execution based on checks.
In the first argument, an object with the event data is received, where name
is the name of the event emitted and args
are the arguments of that event, so checking what the name of the event is, the typing of the arguments is automatically defined:
You can run the block
function to block the execution of events.
In the case of events, it is also possible to pass tags as arguments to the block function. This way, you can have 3 events of the same type, for example messageCreate
, but block only those with the previously defined tags:
You can pass as many tags as you want to the block function.
All events that contain any of the tags passed as arguments to the block function will not be executed.