js-discord-modularcommand 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,17 +6,12 @@ A module to create and manage modular commands in a simple way for Discord.js bo
6
6
 
7
7
  This library simplifies the creation and management of slash commands for [Discord.js](https://discord.js.org/). It allows you to structure your commands in a modular way, making it easier to handle logic, permissions, cooldowns, localizations, and interactive components like buttons and modals.
8
8
 
9
- The main classes are:
10
- - [`ModularCommand`](src/modularcommand.ts): To define the base structure of a command.
11
- - [`ModularButton`](src/modularcommand.ts): To create interactive buttons associated with a command.
12
- - [`ModularModal`](src/modularcommand.ts): To create modals (forms) that the user can fill out.
13
-
14
9
  ## How to use it?
15
10
 
16
11
  First, install the package in your project:
17
12
 
18
13
  ```sh
19
- npm install js-discord-modularcommand
14
+ npm install js-discord-modularcommand@latest
20
15
  ```
21
16
 
22
17
  Then, you can create your commands in a modular fashion. Here is a basic example of a `ping` command:
@@ -24,7 +19,7 @@ Then, you can create your commands in a modular fashion. Here is a basic example
24
19
  ```javascript
25
20
  // filepath: commands/ping.js
26
21
  const { ModularCommand, RegisterCommand } = require('js-discord-modularcommand');
27
- const { PermissionFlagsBits } = require('discord.js');
22
+ const { PermissionFlagsBits, Locale } = require('discord.js');
28
23
 
29
24
  // Create a new command instance
30
25
  const PingCommand = new ModularCommand('ping');
@@ -37,15 +32,31 @@ PingCommand.setPermissionCheck(async ({ interaction }) => {
37
32
  return interaction.member.permissions.has(PermissionFlagsBits.Administrator);
38
33
  });
39
34
 
40
- // Define the logic to be executed
41
- PingCommand.setExecute(async ({ interaction }) => {
42
- await interaction.reply('Pong!');
35
+ // Optional: Localization to use with 'locale'
36
+ pong.setLocalizationPhrases({
37
+ [Locale.EnglishUS]: {
38
+ response: 'Replies with Pong!',
39
+ },
40
+ [Locale.SpanishLATAM]: {
41
+ response: 'Responde con Pong!',
42
+ }
43
+ });
44
+
45
+ // Set the command's description
46
+ pong.setDescription('Replies with Pong!');
47
+
48
+ // Optional: Add more localization descriptions for the command itself
49
+ pong.setLocalizationDescription({
50
+ [Locale.EnglishUS]: 'Replies with Pong!',
51
+ [Locale.SpanishLATAM]: 'Responde con Pong!',
52
+ });
53
+
54
+ // Set the executor function
55
+ pong.setExecute(async ({ interaction, locale }) => {
56
+ await interaction.reply(locale['response']);
43
57
  });
44
58
 
45
- // Register the command so it can be used by the Discord.js client
46
- module.exports = RegisterCommand([
47
- PingCommand
48
- ]);
59
+ module.exports = RegisterCommand(pong)
49
60
  ```
50
61
 
51
62
  In your main file, you can load the commands and register their executors with your Discord client.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-discord-modularcommand",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "discord",