About
slash-register is a module that manage your slash-command, But instead of "deleting" and "re-registering" everytime, the module will only "POST", "DELETE" and "UPDATE" when it's needed, lowering the bandwith down.
Installation
Node.js 16.9.0 or newer is required.
npm install slash-register @discordjs/builders
yarn add slash-register @discordjs/builders
pnpm add slash-register @discordjs/builders
Example usage
Javascript
const { SlashCommandBuilder } = require('@discordjs/builders'),
{ SlashRegister } = require('slash-register');
const slashRegister = new SlashRegister();
(async () => {
console.log('Starting...');
slashRegister.login('YOUR TOKEN');
[
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!')
].forEach((builder) => slashRegister.addGlobalCommand(builder.toJSON()));
console.log('Commands registered! Syncing...');
await slashRegister.sync();
})();
Typescript
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashRegister } from 'slash-register';
const slashRegister = new SlashRegister();
(async () => {
console.log('Starting...');
slashRegister.login('YOUR TOKEN');
[
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!')
].forEach((builder) => slashRegister.addGlobalCommand(builder.toJSON()));
console.log('Commands registered! Syncing...');
await slashRegister.sync();
})();
Don't like the implementation?
- You can implement your own manager! This package provided a utility class called "EqualUtility" to check if two command is equal, So you don't have to implement your own checker!
Links
Note
- This README are yoinked from discord.js.
- The code to check if command are equal is yoinked from discord.js.