Create commands
Explains how to set up commands

Directory structure

This is an example directory structure
Commands - // Directory containing commands

Example code in index.js

Initializing the Object
// Regular Discord.js Stuff
const Discord = require("discord.js");
const client = new Discord.Client({ shardCount: 1 });
// Now we initialize the Object
const { Commands } = require("djs-command-control");
const commands = new Commands(
"Commands", // The `Commands` Directory as specified above
prefix: process.env.PREFIX,
prefixOnMention: true,

Code appearing in Commands/example.js

Example code setup for the file inside the example command
// First importing the class
const { Command } = require("djs-command-control");
// Instatiate the object
const command = new Command();
// Setting up all the variables = "example";
command.description = "An Example Command";
command.invokes = ["example", "ex"]; // Command can both be invoked with 'ex' and 'example'
command.usage = "{{Example Parameter}}";
command.permission = ["MANAGE_GUILD"]; // Command can only be executed by users holding the MANAGE_GUILD permission
command.category = "general"; // The command should appear in the 'general' category
command.execute = async (message, options) => {
// Do some example stuff
command.omitHelp = false; // This command should appear in Command
// Export the command
module.exports = command;
Copy link
On this page
Directory structure
Example code in index.js
Code appearing in Commands/example.js