You can join my Discord Server Support
OR
You can add me in discord: TheOldZoom
ZoomHandler is a event & slashCommand & messageCommand handler related to Discord.js v14
You can install ZoomHandler via npm:
npm install zoomhandler
or you can use npx:
npx zoomhandler
Make sure to have Zoom-Logger & Discord.js installed
To use ZoomHandler in your project, follow these steps:
-
Import ZoomHandler: Import the ZoomHandler module into your project.
const { ZoomHandler } = require("zoomhandler");
-
Create an Instance: Create an instance of the ZoomHandler class, providing necessary configuration options.
new ZoomHandler({ client, messageCommandsPath: path.join(__dirname, "messageCommands"), interactionCommandsPath: path.join(__dirname, "interactionCommands"), eventsPath: path.join(__dirname, "events"), });
client
: Your Zoom client instance.messageCommandsPath
: The path to the directory containing your message command files.interactionCommandsPath
: The path to the directory containing your interaction command files.eventsPath
: The path to the directory containing your event files.
-
Define Message Commands: Define your commands in separate files within the specified
messageCommandsPath
. Each command file should export a function containing the command logic.
module.exports = {
data: {
name: "ping",
description: "Ping! Pong!",
},
run: async ({ message, args, client }) => {
message.channel.send("Pong!");
},
};
Make sure to define your prefix in your main file or where your client is handled.
client.prefix = "prefix";
-
Define Events: Define your events in separate files within the specified
eventsPath
. Each event file should export a function containing the discord.js event logic. -
Execute Commands: Execute commands using the methods provided by ZoomHandler.
Here's an example demonstrating how to use ZoomHandler:
const { ZoomHandler } = require("zoomhandler");
client.prefix = ".";
new ZoomHandler({
client,
messageCommandsPath: path.join(__dirname, "messageCommands"),
interactionCommandsPath: path.join(__dirname, "interactionCommands"),
eventsPath: path.join(__dirname, "events"),
});
Here's how you should use ZoomHandler with discord.js
const { Client, GatewayIntentBits } = require("discord.js");
const { Logger } = require("zoom-logger");
const path = require("path");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
],
});
const { ZoomHandler } = require("zoomhandler");
client.prefix = ".";
new ZoomHandler({
client,
messageCommandsPath: path.join(__dirname, "messageCommands"),
interactionCommandsPath: path.join(__dirname, "interactionCommands"),
eventsPath: path.join(__dirname, "events"),
});
client.login("Your bot token");
Here's an example of how to use an event file: Make sure that the event file is inside a directory that is named the same event name as you like.
// events/ready/ready.js
module.exports = (client) => {
console.log(`${client.user.tag} is ready !`);
};
// events/messageCreate.js
module.exports = (client, message) => {
console.log(message.content);
};
Here's an example of how to use an MessageCreate command File
// messageCommands/ping.js
// messageCommands/general/ping.js
module.exports = {
data: {
name: "ping",
description: "Ping! Pong!",
},
run: async ({ message, args, client }) => {
message.channel.send("Pong!");
},
};
Here's an example of how to use an interactionCreate command File
// interactionCommands/ping.js
// interactionCommands/general/ping.js
const { SlashCommandBuilder } = require("@discordjs/builders");
module.exports = {
data: new SlashCommandBuilder().setName("ping").setDescription("Ping Pong!"),
run: async ({ interaction, client }) => {
await interaction.reply("Pong!");
},
};
- validations (Before executing the code).
- better documentation.