zoomhandler

0.2.5 • Public • Published

ZoomHandler Documentation

How To Get Support

You can join my Discord Server Support

OR

You can add me in discord: TheOldZoom

Overview

ZoomHandler is a event & slashCommand & messageCommand handler related to Discord.js v14

Installation

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

Usage

To use ZoomHandler in your project, follow these steps:

  1. Import ZoomHandler: Import the ZoomHandler module into your project.

    const { ZoomHandler } = require("zoomhandler");
  2. 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.
  3. 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";
  1. 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.

  2. Execute Commands: Execute commands using the methods provided by ZoomHandler.

Example

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");

Example Event File

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);
};

Example MessageCreate Command File

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!");
  },
};

Example interactionCreate Command File

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!");
  },
};

Developer To-Do

  • validations (Before executing the code).
  • better documentation.

Package Sidebar

Install

npm i zoomhandler

Weekly Downloads

158

Version

0.2.5

License

ISC

Unpacked Size

14.7 kB

Total Files

11

Last publish

Collaborators

  • theoldzoom