Creating Commands
Any file you create inside your provided commandsPath
will be counted as a command file. It doesn't matter how nested it is. Take this for example:
I've created a ping.js
file inside of my defined commands path. This file is expected to export an object by default that looks something like this.
Your command file is expected to export an object with a data
property which is the structure of the command itself, and a run
method which is called when this command is triggered.
If you don't like using the Slash Command Builder (🙋♂️), then you can directly create an object that looks something like this.
Run Method Parameters
You can destructure interaction
, client
, and handler
from the run
method to help handle your command. Here's more information on each one of them.
interaction
: This is the interaction object returned by theinteractionCreate
event listener.client
: This is your Discord.jsClient
instance which was defined in the main entry point of your project.handler
: This is the DJS-CommanderCommandHandler
instance which was also defined in the main entry point of your project.
Last updated