Skip to Content
nyx logonyx guide

Executor

See in:
djs/DefaultCommandExecutorGitHub
djs-core/DefaultCommandExecutorGitHub
CommandExecutorGitHub
Reading time:2 min read

The CommandExecutor is responsible for executing commands, making sure the middleware passes and handling errors.

When to override

✅ Override if you want to...❌ Don't override if you want to...
Customize how commands are executed.Listen for command runs. Use the EventBus in the CommandManager instead.
Add advanced logic while executing a command, like delaying calls.Add new middlewares or error consumers. You can interact with the MiddlewareList and ErrorHandler objects directly, using the getter on the executor.
Override the default MiddlewareList or ErrorHandler. You can do that already from the DefaultCommandExecutor.create() options, as shown in the respective guide of the object you want to override.

Overriding

Creation

Create a custom executor by either:

  • Extending DefaultCommandExecutor (recommended, less work).
  • Implementing CommandExecutor.
import {  } from '@nyx-discord/djs';

class  extends  {}

Registration

Create it and set it to the CommandManager.

class  extends  {}

.().(.());

The create() method instantiates the executor with the default ErrorHandler and MiddlewareList (which are overridable, as described below). It'll also instantiate your custom class, not the base one.

Dependencies

You can override the executor's dependencies (ErrorHandler and MiddlewareList) by passing them as options to the DefaultCommandExecutor.create() method. More details in the respective guides:

Edit on GitHub

Last updated on

On this page