load-slash-commands

2.5.6 • Public • Published

load-slash-commands

This module is a module for quickly loading commands from main file without needing any mess in the root directory.

Usage

Using this module is pretty simple, here is an example using Discord.JS:

const registerCommands = require("register-slash-commands");
const {Client, Intents} = require("discord.js");
const client = new Client({intents: [Intents.flags.GUILDS]});

const commands = [
  {
    name: "ping",
    description: "Sends the client's WebSocket latency."
  }
];
client.on("ready", () => {
  registerCommands(client, commands);
});

client.on("interactionCreate", (int) => {
  if(!int.isCommand()) return;
  if(int.commandName == "ping"){
    int.reply(`My latency is ${client.ws.ping} ms.`);
  }
});

Or if you want to use guild specific commands:

const registerCommands = require("register-slash-commands");
const {Client, Intents} = require("discord.js");
const client = new Client({intents: [Intents.flags.GUILDS]});
const guildId = "846496831533088768";

const commands = [
  {
    name: "ping",
    description: "Sends the client's WebSocket latency."
  }
];
client.on("ready", () => {
  registerCommands(client, commands, guildId);
});

client.on("interactionCreate", (int) => {
  if(!int.isCommand()) return;
  if(int.commandName == "ping"){
    int.reply(`My latency is ${client.ws.ping} ms.`);
  }
});

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.5.60latest

Version History

VersionDownloads (Last 7 Days)Published
2.5.60
2.5.50
2.4.50
2.3.50
1.3.50
1.3.00
1.2.00
1.0.00

Package Sidebar

Install

npm i load-slash-commands

Weekly Downloads

0

Version

2.5.6

License

ISC

Unpacked Size

2.33 kB

Total Files

3

Last publish

Collaborators

  • ecolipsy