1.3.5 • Published 2 years ago
@louiszn/discordjs-helper v1.3.5
✨ Discord.JS - Helper ✨
About
Discordjs-helper is an assistant that makes it easier for you to use discord.js.
- Fast performance
- Shorten your code
- Easy to learn
Installation
Requirement: Discord.JS v14
$ npm install @louiszn/discordjs-helper
$ yarn add @louiszn/discordjs-helper
$ pnpm add @louiszn/discordjs-helper
Example Usage
Hybrid command
discord-bot/
├──commands
│ ├── ping.js
├──node_modules
├──index.js
├──package-lock.json
└──package.json
Start the handler
// index.js - CommonJS
const { Client } = require('discord.js');
const { LoadHybridCommand, Intents, Partials } = require('@louiszn/discordjs-helper');
const client = new Client({
intents: [Intents.All],
partials: [Partials.All],
});
LoadHybridCommand(client, {
bot_prefix: '.', // ["prefix_1", "prefix_2"], function return string or string[]
command_dir: 'commands',
default_exports: true,
});
client.on('ready', async () => console.log(`${client.user.tag} is ready!`));
client.login('YOUR_BOT_TOKEN');
// index.js - ECMAScript modules
import { Client } from 'discord.js';
import { LoadHybridCommand, Intents, Partials } from '@louiszn/discordjs-helper';
const client = new Client({
intents: [Intents.All],
partials: [Partials.All],
});
LoadHybridCommand(client, {
bot_prefix: '.', // ["prefix_1", "prefix_2"], function return string or string[]
command_dir: 'commands',
default_exports: true,
});
client.on('ready', async () => console.log(`${client.user.tag} is ready!`));
client.login('YOUR_BOT_TOKEN');
Example command
// ping.js - CommonJS
const { HybridCommand } = require('@louiszn/discordjs-helper');
module.exports = new HybridCommand({
name: 'ping',
description: 'Pong',
run: async (client, ctx, args) => {
ctx.send({ content: `Pong! ${client.ws.ping}ms!` });
},
});
// ping.js ECMAScript modules
import { HybridCommand } from '@louiszn/discordjs-helper';
export default new HybridCommand({
name: 'ping',
description: 'Pong',
run: async (client, ctx, args) => {
ctx.send({ content: `Pong! ${client.ws.ping}ms!` });
},
});
Preview