This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

djs-ghandler

0.1.1 • Public • Published

djs-ghandler: A Library for Discord.js Projects

djs-ghandler is an easy-to-use JavaScript library that simplifies the process of handling commands, events, and validations in your Discord.js projects.

Discord.js version supported: v14

Installation

To install djs-ghandler, simply run the following command:

For npm:

npm install djs-ghandler

Usage

// index.js
const { Client, GatewayIntentBits } = require("discord.js");
const { Handler } = require("djs-ghandler");

const client = new Client({
    intents: [Object.keys(GatewayIntentBits)]
});

const handler = new Handler(client, {
    commandsPath: "COMMAND_PATH", // You can using path module from node.js
    eventPath: "EVENT_PATH", // Same like commandPath, You can using path module from node.js
    ext: ".js" // .js is a deafult extension in this class you can chance it to readable script like .ts
});

client.login("TOKEN");

File Structure

Any file inside the commands directory will be considered a command file, so make sure it properly exports an object. Like this:

// commands/ping.js
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
  data: new SlashCommandBuilder().setName('ping').setDescription('Pong!'),

  execute: ({ interaction, client, fileData }) => {
    interaction.reply(`Pong! ${client.ws.ping}ms`);
  },
};
  • interaction
  • client is the discord.js Client instance.

Events

DJS-GHandler assumes a specific file structure for your events. Here's an example of what your file structure could look like:

events/
├── ready/
|	├── console-log.js
|	└── webhook.js
|
└── messageCreate/
	├── auto-mod/
	|	├── delete-swear-words.js
	|	└── anti-raid.js
	|
	└── chat-bot.js

Make sure each file exports a default function. Like this:

// events/ready/console-log.js
module.exports = ({ argument, client }) => {
  console.log(`${client.user.tag} is online.`);
};
  • argument is the argument you receive from the event being triggered (you can name this whatever you want). For example, the messageCreate event will give you an argument of the message object.
  • client is the discord.js Client instance.

Package Sidebar

Install

npm i djs-ghandler

Weekly Downloads

0

Version

0.1.1

License

ISC

Unpacked Size

8.72 kB

Total Files

5

Last publish

Collaborators

  • gsentertaimentdev