2.5.6 • Published 2 years ago

load-slash-commands v2.5.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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.`);
  }
});
2.5.6

2 years ago

2.5.5

2 years ago

2.4.5

2 years ago

2.3.5

2 years ago

1.3.5

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.0.0

2 years ago