A guide for using middleware in ShadowCore.
/middleware
directory and categorized into subfolders.
Example Folder Structure:
beforeExecution
function runs before the command executes, and the afterExecution
function runs after the command has finished executing.
ping
command:
name
is "ping"
, so this middleware will only apply to the ping
command.beforeExecution
function is executed before the command runs.afterExecution
function is executed after the command completes.name
is "global"
, so this middleware will apply to all commands.beforeExecution
and afterExecution
functions will be run for every command.beforeExecution
function is called before the command executes. If beforeExecution
returns false
, the command will be blocked and will not execute.
After the command runs, the afterExecution
function is called. This happens regardless of whether the command was successful or not. afterExecution
only runs if beforeExecution
returned true
.
afterExecution
is executed.afterExecution
is executed last.