
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
discordjs-modules
Advanced tools
Discord.js modules handler that allows you handle all discord components and interactions like menus, modals, button, events and commands in one module directory.
Discord.js modules handler that allows you handle all discord components (like menus, modals and buttons), events and commands in one module directory. You can easily add new features or remove old ones, just add or remove a module (folder) from the modules directory.
via npm
npm i discordjs-modules
via yarn
yarn add discordjs-modules
Import the handler initialization function into the main index.ts file
// index.ts
import { DiscordJSModules } from "discordjs-modules";
import { Client, GatewayIntentBits, Partials, Collection } from "discord.js";
import config from "./config.json";
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages],
});
DiscordJSModules.init(client, config.token, { srcDir: __dirname });
client.login(config.token);
After starting the bot, the handler will create a new modules directory in the root folder. There you can create your own module as shown below:
├───node_modules
├───src
│ ├───index.ts
│ ├───modules <-- this folder will be created automatically
│ │ └───myFirstModule <-- this is a module created by you, name it whatever you want
│ │ ├───commands <-- this is commands directory, must always be named 'commands'
│ │ │ └───ban.ts (command file)
│ │ ├───buttons <-- this is buttons directory, must always be named 'buttons'
│ │ │ └───submit.ts (button file)
│ │ ├───modals <-- this is modals directory, must always be named 'modals'
│ │ │ └───form.ts (modal file)
│ │ ├───events <-- this is events directory, must always be named 'events'
│ │ │ └───messageCreate.ts (event file)
│ │ └───menus <-- this is menus directory, must always be named 'menus'
│ │ └───select-user.ts (menu file)
│ └───utils
│ └───discord
├───package.json
├───package-lock.json
├───config.json
[!IMPORTANT]
Remember! You must always use the correct directory names:
/commandsfor commands files
/eventsfor events files
/buttonsfor buttons files
/menusfor menus files
/modalsfor modal files
Each component requires an appropriate structure of the exported object to work:
/commands/ban.ts
import { SlashCommandBuilder } from "discord.js";
import { CommandModule } from "discordjs-modules";
module.exports = <CommandModule<SlashCommandBuilder>>{
data: new SlashCommandBuilder().setName("ban").setDescription("Ban user"),
cooldown: 5, // (optional cooldown in seconds)
async autocomplete(interaction) { // (optional)
// your code to execute when autocomplete option is set to true
},
execute(interaction) {
// your code to execute
},
};
/events/messageCreate.ts
import { Events } from "discord.js";
import { EventModule } from "discordjs-modules";
module.exports = <EventModule<Events.MessageCreate>>{
name: Events.MessageCreate,
async execute(message) {
// your code to execute
},
};
/buttons/submit.ts
[!NOTE]
Buttons, menus and modals have the same file structure.
import { ButtonModule } from "discordjs-modules";
// or import { MenuModule } from "discordjs-modules"; if its menu file
// or import { ModalModule } from "discordjs-modules"; if its modal file
module.exports = <ButtonModule>{
customId: "submit",
async execute(interaction) {
// your code to execute
},
};
The handler allows you to create global events and commands that do not need to be assigned to any module. All you need to do is create a commands or events folder in the project's root directory. The files structure is the same as in the modules.
├───node_modules
├───src
│ ├───index.ts
│ ├───commands <-- global commands here
│ │ └───globalCommand.ts
│ ├───events <-- global events here
│ │ └───guildMemberAdd.ts
│ ├───modules <-- this folder will be created automatically
│ │ └───myFirstModule <-- this is a module created by you, name it whatever you want
│ │ ├───commands <-- this is commands directory, must always be named 'commands'
│ │ │ └───ban.ts (command file)
│ │ ├───buttons <-- this is buttons directory, must always be named 'buttons'
│ │ │ └───submit.ts (button file)
│ │ ├───modals <-- this is modals directory, must always be named 'modals'
│ │ │ └───form.ts (modal file)
│ │ ├───events <-- this is events directory, must always be named 'events'
│ │ │ └───messageCreate.ts (event file)
│ │ └───menus <-- this is menus directory, must always be named 'menus'
│ │ └───select-user.ts (menu file)
│ └───utils
│ └───discord
├───package.json
├───package-lock.json
├───config.json
FAQs
Discord.js modules handler that allows you handle all discord components and interactions like menus, modals, button, events and commands in one module directory.
The npm package discordjs-modules receives a total of 0 weekly downloads. As such, discordjs-modules popularity was classified as not popular.
We found that discordjs-modules demonstrated a not healthy version release cadence and project activity because the last version was released 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.