
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
djs-commands
Advanced tools
an all-in-one command handler package.
npm install djs-commands
1 - Require and create a CommandHandler instance
Pass through the Discord Client instantiated from Discord.js, your token (this may be optional in the future but is needed to register slash commands), and the folder path that houses your command files.
const { CommandHandler } = require("djs-commands");
const handler = new CommandHandler(client, token, folder_path);
2 - In the interactionCreate event is where we will run our command
client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand()) return;
let cmd = handler.getCommand(interaction.commandName);
if (!cmd) return;
try {
cmd.run(interaction);
} catch (e) {
console.log(e);
}
});
3 - And of course we're going to need a command file. So inside of your bot folder, create a folder called commands. I'm going to create a file called test.js and put the following code inside of it.
The this.slashCommand option takes a SlashCommandBuilder() passed as a JSON type. You can add whatever slash command options you like here using discordjs/builders.
const { SlashCommandBuilder } = require("discordjs");
module.exports = class test {
constructor() {
((this.name = "test"),
(this.slashCommand = new SlashCommandBuilder()
.setName("test")
.setDescription("A command to test stuff and things.")));
}
async run(interaction) {
await interaction.reply(this.name + " works");
}
};
4 - And that's it! You have a working command handler now for all the commands you could want! Here's an example of how to add options to a slash command.
const { SlashCommandBuilder } = require("discordjs");
module.exports = class another {
constructor() {
((this.name = "another"),
(this.slashCommand = new SlashCommandBuilder()
.setName("another")
.setDescription("Another command to test stuff and things.")
.addBooleanOption((option) =>
option
.setName("stuff")
.setDescription("a description")
.setRequired(true),
)));
}
async run(interaction) {
await interaction.reply(this.name + " works");
}
};
And then from there, you can add as many options or whatever type of option you wish using the link above.
https://github.com/nedinator/djs-commands
git checkout -b feature/fooBar)git commit -am 'Add some fooBar')git push origin feature/fooBar)FAQs
a command handler for slash commands on discordjs
The npm package djs-commands receives a total of 39 weekly downloads. As such, djs-commands popularity was classified as not popular.
We found that djs-commands demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.