js-discord-modularcommand 1.0.1 → 2.0.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.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # JS Discord ModularCommand
2
+
3
+ A module to create and manage modular commands in a simple way for Discord.js bots.
4
+
5
+ ## What is it for?
6
+
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
+
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
+ ## How to use it?
15
+
16
+ First, install the package in your project:
17
+
18
+ ```sh
19
+ npm install js-discord-modularcommand
20
+ ```
21
+
22
+ Then, you can create your commands in a modular fashion. Here is a basic example of a `ping` command:
23
+
24
+ ```javascript
25
+ // filepath: commands/ping.js
26
+ const { ModularCommand, RegisterCommand } = require('js-discord-modularcommand');
27
+ const { PermissionFlagsBits } = require('discord.js');
28
+
29
+ // Create a new command instance
30
+ const PingCommand = new ModularCommand('ping');
31
+
32
+ // Set the description
33
+ PingCommand.setDescription('Sends a ping message!');
34
+
35
+ // Optional: Add a permission check
36
+ PingCommand.setPermissionCheck(async ({ interaction }) => {
37
+ return interaction.member.permissions.has(PermissionFlagsBits.Administrator);
38
+ });
39
+
40
+ // Define the logic to be executed
41
+ PingCommand.setExecute(async ({ interaction }) => {
42
+ await interaction.reply('Pong!');
43
+ });
44
+
45
+ // Register the command so it can be used by the Discord.js client
46
+ module.exports = RegisterCommand([
47
+ PingCommand
48
+ ]);
49
+ ```
50
+
51
+ In your main file, you can load the commands and register their executors with your Discord client.
52
+
53
+ ## License
54
+
55
+ This project is under the MIT License. See the [LICENSE](LICENSE) file
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @file Manages command cooldowns for users to prevent spam.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ /**
7
+ * @interface CooldownStatus
8
+ * @description Represents the cooldown status of a user for a specific command.
9
+ */
10
+ interface CooldownStatus {
11
+ /** Indicates if the user is currently on cooldown. */
12
+ inCooldown: boolean;
13
+ /** The remaining time in seconds until the cooldown expires. It will be 0 if the user is not in cooldown. */
14
+ waitTime: number;
15
+ }
16
+ /**
17
+ * Registers a new command and its cooldown duration in the internal maps.
18
+ * @param {string} name - The name of the command to register.
19
+ * @param {number} duration - The cooldown duration in seconds.
20
+ * @returns {void}
21
+ */
22
+ export declare function cooldownRegister(name: string, duration: number): void;
23
+ /**
24
+ * Gets the last execution timestamp for a user on a specific command.
25
+ * @param {string} name - The name of the command.
26
+ * @param {string} userId - The ID of the user.
27
+ * @returns {number | undefined} The timestamp (in milliseconds) of the last execution, or `undefined` if not found.
28
+ */
29
+ export declare function cooldownGetUser(name: string, userId: string): number | undefined;
30
+ /**
31
+ * Sets the current timestamp for a user on a specific command, effectively starting their cooldown.
32
+ * @param {string} name - The name of the command.
33
+ * @param {string} userId - The ID of the user.
34
+ * @returns {void}
35
+ */
36
+ export declare function cooldownSetUser(name: string, userId: string): void;
37
+ /**
38
+ * Checks if a user is currently on cooldown for a specific command.
39
+ * @param {string} name - The name of the command.
40
+ * @param {string} userId - The ID of the user.
41
+ * @returns {CooldownStatus} An object indicating if the user is in cooldown and the remaining time.
42
+ */
43
+ export default function isUserInCooldown(name: string, userId: string): CooldownStatus;
44
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * @file Manages command cooldowns for users to prevent spam.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.cooldownRegister = cooldownRegister;
9
+ exports.cooldownGetUser = cooldownGetUser;
10
+ exports.cooldownSetUser = cooldownSetUser;
11
+ exports.default = isUserInCooldown;
12
+ // =================================================================================================
13
+ // Module-level State
14
+ // =================================================================================================
15
+ /**
16
+ * @description Stores the cooldown duration configured for each command.
17
+ * @maps Command name (string) to its cooldown duration in seconds (number).
18
+ */
19
+ const COMMAND_CONFIG = new Map();
20
+ /**
21
+ * @description Stores the last execution timestamp for each user on a specific command.
22
+ * @maps Command name (string) to another Map, which in turn maps a user's ID (string) to the execution timestamp (number).
23
+ */
24
+ const COOLDOWNS_MAP = new Map();
25
+ // =================================================================================================
26
+ // Public Functions
27
+ // =================================================================================================
28
+ /**
29
+ * Registers a new command and its cooldown duration in the internal maps.
30
+ * @param {string} name - The name of the command to register.
31
+ * @param {number} duration - The cooldown duration in seconds.
32
+ * @returns {void}
33
+ */
34
+ function cooldownRegister(name, duration) {
35
+ COMMAND_CONFIG.set(name, duration);
36
+ COOLDOWNS_MAP.set(name, new Map());
37
+ }
38
+ ;
39
+ /**
40
+ * Gets the last execution timestamp for a user on a specific command.
41
+ * @param {string} name - The name of the command.
42
+ * @param {string} userId - The ID of the user.
43
+ * @returns {number | undefined} The timestamp (in milliseconds) of the last execution, or `undefined` if not found.
44
+ */
45
+ function cooldownGetUser(name, userId) {
46
+ return COOLDOWNS_MAP.get(name)?.get(userId);
47
+ }
48
+ /**
49
+ * Sets the current timestamp for a user on a specific command, effectively starting their cooldown.
50
+ * @param {string} name - The name of the command.
51
+ * @param {string} userId - The ID of the user.
52
+ * @returns {void}
53
+ */
54
+ function cooldownSetUser(name, userId) {
55
+ COOLDOWNS_MAP.get(name)?.set(userId, Date.now());
56
+ }
57
+ /**
58
+ * Checks if a user is currently on cooldown for a specific command.
59
+ * @param {string} name - The name of the command.
60
+ * @param {string} userId - The ID of the user.
61
+ * @returns {CooldownStatus} An object indicating if the user is in cooldown and the remaining time.
62
+ */
63
+ function isUserInCooldown(name, userId) {
64
+ const lastTime = cooldownGetUser(name, userId);
65
+ // If the user has never used the command, they are not on cooldown.
66
+ if (lastTime === undefined) {
67
+ return { inCooldown: false, waitTime: 0 };
68
+ }
69
+ const timePassed = (Date.now() - lastTime) / 1000; // Time passed in seconds
70
+ const cooldownCommand = COMMAND_CONFIG.get(name);
71
+ // This error indicates a developer mistake, as a command should be registered before being checked.
72
+ if (cooldownCommand === undefined) {
73
+ throw new Error(`Command '${name}' isn't registered in the cooldown system.`);
74
+ }
75
+ if (timePassed < cooldownCommand) {
76
+ // If the time passed is less than the required cooldown, the user is still on cooldown.
77
+ return { inCooldown: true, waitTime: cooldownCommand - timePassed };
78
+ }
79
+ // Otherwise, the cooldown has expired.
80
+ return { inCooldown: false, waitTime: 0 };
81
+ }
@@ -0,0 +1,10 @@
1
+ import { LOCALE_DELAY, LOCALE_ERROR, LOCALE_FORBIDDEN, LOCALE_NSFW } from "./locales";
2
+ import ModularCommandHandler from "./interaction";
3
+ import { CommandData } from "./types";
4
+ import ModularModal from "./modularmodal";
5
+ import ModularCommand from "./modularcommand";
6
+ import ModularButton from "./modularbutton";
7
+ import RegisterCommand from "./registercommand";
8
+ import LoadCommand from "./loadcommands";
9
+ export default ModularCommand;
10
+ export { ModularCommand, ModularButton, ModularModal, CommandData, RegisterCommand, LoadCommand, ModularCommandHandler, LOCALE_DELAY, LOCALE_ERROR, LOCALE_FORBIDDEN, LOCALE_NSFW };
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LOCALE_NSFW = exports.LOCALE_FORBIDDEN = exports.LOCALE_ERROR = exports.LOCALE_DELAY = exports.ModularCommandHandler = exports.LoadCommand = exports.RegisterCommand = exports.ModularModal = exports.ModularButton = exports.ModularCommand = void 0;
7
+ const locales_1 = require("./locales");
8
+ Object.defineProperty(exports, "LOCALE_DELAY", { enumerable: true, get: function () { return locales_1.LOCALE_DELAY; } });
9
+ Object.defineProperty(exports, "LOCALE_ERROR", { enumerable: true, get: function () { return locales_1.LOCALE_ERROR; } });
10
+ Object.defineProperty(exports, "LOCALE_FORBIDDEN", { enumerable: true, get: function () { return locales_1.LOCALE_FORBIDDEN; } });
11
+ Object.defineProperty(exports, "LOCALE_NSFW", { enumerable: true, get: function () { return locales_1.LOCALE_NSFW; } });
12
+ const interaction_1 = __importDefault(require("./interaction"));
13
+ exports.ModularCommandHandler = interaction_1.default;
14
+ const modularmodal_1 = __importDefault(require("./modularmodal"));
15
+ exports.ModularModal = modularmodal_1.default;
16
+ const modularcommand_1 = __importDefault(require("./modularcommand"));
17
+ exports.ModularCommand = modularcommand_1.default;
18
+ const modularbutton_1 = __importDefault(require("./modularbutton"));
19
+ exports.ModularButton = modularbutton_1.default;
20
+ const registercommand_1 = __importDefault(require("./registercommand"));
21
+ exports.RegisterCommand = registercommand_1.default;
22
+ const loadcommands_1 = __importDefault(require("./loadcommands"));
23
+ exports.LoadCommand = loadcommands_1.default;
24
+ exports.default = modularcommand_1.default;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file Contains the logic for handling Discord bot interactions.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { BaseInteraction, CommandInteraction, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
7
+ import { ClientWithCommands } from "./types";
8
+ /**
9
+ * @interface InteractionHandlerArgs
10
+ * @description Defines the arguments for the custom interaction handler function.
11
+ */
12
+ interface InteractionHandlerArgs {
13
+ /** The interaction received from Discord. */
14
+ interaction: CommandInteraction | MessageComponentInteraction | ModalSubmitInteraction;
15
+ }
16
+ /**
17
+ * @type InteractionHandler
18
+ * @description A function signature for a custom interaction handler.
19
+ * @returns {Promise<boolean | undefined>} A promise that resolves to `false` to stop the default handler, or `true`/`undefined` to continue.
20
+ */
21
+ type InteractionHandler = (args: InteractionHandlerArgs) => Promise<boolean | undefined>;
22
+ /**
23
+ * @description Creates a modular command handler function for the Discord client.
24
+ * @param {ClientWithCommands} client The Discord client instance with a commands collection.
25
+ * @param {InteractionHandler} customHandler A custom function to handle interactions before the default logic.
26
+ * @returns {(interaction: BaseInteraction) = Promise<void>} The main interaction handler function.
27
+ */
28
+ export default function ModularCommandHandler(client: ClientWithCommands, customHandler: InteractionHandler): (interaction: BaseInteraction) => Promise<void>;
29
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * @file Contains the logic for handling Discord bot interactions.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.default = ModularCommandHandler;
9
+ const discord_js_1 = require("discord.js");
10
+ const locales_1 = require("./locales");
11
+ // =================================================================================================
12
+ // Main Handler Function
13
+ // =================================================================================================
14
+ /**
15
+ * @description Creates a modular command handler function for the Discord client.
16
+ * @param {ClientWithCommands} client The Discord client instance with a commands collection.
17
+ * @param {InteractionHandler} customHandler A custom function to handle interactions before the default logic.
18
+ * @returns {(interaction: BaseInteraction) = Promise<void>} The main interaction handler function.
19
+ */
20
+ function ModularCommandHandler(client, customHandler) {
21
+ if (!client.commands) {
22
+ throw new Error(`Client is missing the 'commands' collection.`);
23
+ }
24
+ if (!(client.commands instanceof discord_js_1.Collection)) {
25
+ throw new Error(`Client.commands is not an instance of Discord.js Collection.`);
26
+ }
27
+ const handler = async (interaction) => {
28
+ if (!interaction.isChatInputCommand() && !interaction.isMessageComponent() && !interaction.isModalSubmit()) {
29
+ return;
30
+ }
31
+ const response = await customHandler({ interaction });
32
+ if (response === false)
33
+ return;
34
+ let commandName;
35
+ if (interaction.isChatInputCommand()) {
36
+ commandName = interaction.commandName;
37
+ }
38
+ else if (interaction.customId) {
39
+ commandName = interaction.customId.split('_')[0];
40
+ }
41
+ else {
42
+ const errorMessage = locales_1.LOCALE_ERROR[interaction.locale];
43
+ if (interaction.replied || interaction.deferred) {
44
+ await interaction.followUp({ content: errorMessage, flags: discord_js_1.MessageFlags.Ephemeral });
45
+ }
46
+ else {
47
+ await interaction.reply({ content: errorMessage, flags: discord_js_1.MessageFlags.Ephemeral });
48
+ }
49
+ console.error(`Interaction does not have a commandName or customId: ${interaction.id}`);
50
+ return;
51
+ }
52
+ const command = client.commands.get(commandName);
53
+ if (command === undefined) {
54
+ console.error(`No command found for interaction: ${interaction.id} with command name: ${commandName}`);
55
+ return;
56
+ }
57
+ try {
58
+ if (interaction.isChatInputCommand()) {
59
+ await command.execute(interaction);
60
+ }
61
+ else if (interaction.isButton() && command.buttonExecute) {
62
+ await command.buttonExecute(interaction);
63
+ }
64
+ else if (interaction.isMessageComponent() && command.componentExecute) {
65
+ await command.componentExecute(interaction);
66
+ }
67
+ else if (interaction.isModalSubmit() && command.modalExecute) {
68
+ await command.modalExecute(interaction);
69
+ }
70
+ }
71
+ catch (error) {
72
+ const errorMessage = locales_1.LOCALE_ERROR[interaction.locale];
73
+ if (interaction.replied || interaction.deferred) {
74
+ await interaction.followUp({ content: errorMessage, flags: discord_js_1.MessageFlags.Ephemeral });
75
+ }
76
+ else {
77
+ await interaction.reply({ content: errorMessage, flags: discord_js_1.MessageFlags.Ephemeral });
78
+ }
79
+ console.error(`Error handling interaction: ${interaction.id}`, error);
80
+ }
81
+ };
82
+ return handler;
83
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file Contains the logic for loading modular commands into the Discord bot client.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { CommandData } from "./types";
7
+ /**
8
+ * @description Loads one or more commands into an array.
9
+ * @param {CommandData[]} commandsArray The array where the loaded commands will be stored.
10
+ * @param {CommandData | CommandData[]} command The command(s) to load. Can be a single `CommandData` object or an array of them.
11
+ * @throws {TypeError} If a command is missing the `execute` function.
12
+ * @example
13
+ * ```typescript
14
+ * import { Collection } from "discord.js";
15
+ * import LoadCommand from "./loadcommands";
16
+ * import exampleCommand from "./commands/example";
17
+ *
18
+ * const commandsList: CommandData[] = [];
19
+ * LoadCommand(commandsList, exampleCommand);
20
+ *
21
+ * const client = { commands: new Collection<string, CommandData>() };
22
+ * for (const cmd of commandsList) {
23
+ * client.commands.set(cmd.data.name, cmd);
24
+ * }
25
+ * ```
26
+ */
27
+ export default function LoadCommand(commandsArray: CommandData[], command: CommandData | CommandData[]): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * @file Contains the logic for loading modular commands into the Discord bot client.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.default = LoadCommand;
9
+ // =================================================================================================
10
+ // Main Loading Function
11
+ // =================================================================================================
12
+ /**
13
+ * @description Loads one or more commands into an array.
14
+ * @param {CommandData[]} commandsArray The array where the loaded commands will be stored.
15
+ * @param {CommandData | CommandData[]} command The command(s) to load. Can be a single `CommandData` object or an array of them.
16
+ * @throws {TypeError} If a command is missing the `execute` function.
17
+ * @example
18
+ * ```typescript
19
+ * import { Collection } from "discord.js";
20
+ * import LoadCommand from "./loadcommands";
21
+ * import exampleCommand from "./commands/example";
22
+ *
23
+ * const commandsList: CommandData[] = [];
24
+ * LoadCommand(commandsList, exampleCommand);
25
+ *
26
+ * const client = { commands: new Collection<string, CommandData>() };
27
+ * for (const cmd of commandsList) {
28
+ * client.commands.set(cmd.data.name, cmd);
29
+ * }
30
+ * ```
31
+ */
32
+ function LoadCommand(commandsArray, command) {
33
+ const commands = Array.isArray(command) ? command : [command];
34
+ for (const cmd of commands) {
35
+ if (typeof cmd.execute !== "function") {
36
+ throw new TypeError(`Command "${cmd.data.name}" is missing a required 'execute' function.`);
37
+ }
38
+ commandsArray.push(cmd);
39
+ }
40
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @file Contains the generic localization phrases used throughout the application.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { Locale } from "discord.js";
7
+ import LOCALE_DELAY, { ModularLocale } from "./modularlocale";
8
+ /**
9
+ * @description Localization phrases for various commands, specifically for permission errors.
10
+ */
11
+ declare const LOCALE_FORBIDDEN: Record<Locale, string>;
12
+ /**
13
+ * @description Localization phrases for NSFW command usage errors.
14
+ */
15
+ declare const LOCALE_NSFW: Record<Locale, string>;
16
+ /**
17
+ * @description Localization phrases for general application errors.
18
+ */
19
+ declare const LOCALE_ERROR: Record<Locale, string>;
20
+ export { LOCALE_DELAY, LOCALE_ERROR, LOCALE_FORBIDDEN, LOCALE_NSFW, ModularLocale };
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ /**
3
+ * @file Contains the generic localization phrases used throughout the application.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ModularLocale = exports.LOCALE_NSFW = exports.LOCALE_FORBIDDEN = exports.LOCALE_ERROR = exports.LOCALE_DELAY = void 0;
42
+ const discord_js_1 = require("discord.js");
43
+ const modularlocale_1 = __importStar(require("./modularlocale"));
44
+ exports.LOCALE_DELAY = modularlocale_1.default;
45
+ Object.defineProperty(exports, "ModularLocale", { enumerable: true, get: function () { return modularlocale_1.ModularLocale; } });
46
+ // =================================================================================================
47
+ // Localization Phrases
48
+ // =================================================================================================
49
+ /**
50
+ * @description Localization phrases for various commands, specifically for permission errors.
51
+ */
52
+ const LOCALE_FORBIDDEN = {
53
+ [discord_js_1.Locale.SpanishLATAM]: 'No tienes permiso para usar este comando.',
54
+ [discord_js_1.Locale.EnglishUS]: 'You do not have permission to use this command.',
55
+ [discord_js_1.Locale.EnglishGB]: 'I say, it appears you lack the proper authorisation to utilise this command, old bean.',
56
+ [discord_js_1.Locale.SpanishES]: 'Ostias chaval, tio parece que no vais a poder usar este comando madre mia willy, que barbaridad.',
57
+ [discord_js_1.Locale.PortugueseBR]: 'Você não tem permissão para usar este comando.',
58
+ [discord_js_1.Locale.French]: 'Vous n\'avez pas la permission d\'utiliser cette commande.',
59
+ [discord_js_1.Locale.German]: 'Du hast keine Berechtigung, diesen Befehl zu verwenden.',
60
+ [discord_js_1.Locale.Italian]: 'Non hai il permesso di usare questo comando.',
61
+ [discord_js_1.Locale.Russian]: 'У вас нет разрешения на использование этой команды.',
62
+ [discord_js_1.Locale.ChineseCN]: '您没有权限使用此命令。',
63
+ [discord_js_1.Locale.ChineseTW]: '您沒有權限使用此命令。',
64
+ [discord_js_1.Locale.Japanese]: 'このコマンドを使用する権限がありません。',
65
+ [discord_js_1.Locale.Korean]: '이 명령을 사용할 권한이 없습니다.',
66
+ [discord_js_1.Locale.Bulgarian]: 'Нямате разрешение да използвате тази команда.',
67
+ [discord_js_1.Locale.Czech]: 'Nemáte oprávnění k použití tohoto příkazu.',
68
+ [discord_js_1.Locale.Danish]: 'Du har ikke tilladelse til at bruge denne kommando.',
69
+ [discord_js_1.Locale.Dutch]: 'Je hebt geen toestemming om deze opdracht te gebruiken.',
70
+ [discord_js_1.Locale.Finnish]: 'Sinulla ei ole lupaa käyttää tätä komentoa.',
71
+ [discord_js_1.Locale.Hungarian]: 'Nincs jogosultságod ehhez a parancshoz.',
72
+ [discord_js_1.Locale.Norwegian]: 'Du har ikke behörighet til å bruke denne kommandoen.',
73
+ [discord_js_1.Locale.Polish]: 'Nie masz uprawnień do używania tej komendy.',
74
+ [discord_js_1.Locale.Romanian]: 'Nu ai permisiunea de a folosi acest comandă.',
75
+ [discord_js_1.Locale.Swedish]: 'Du har inte behörighet att använda det här kommandot.',
76
+ [discord_js_1.Locale.Turkish]: 'Bu komutu kullanma izniniz yok.',
77
+ [discord_js_1.Locale.Ukrainian]: 'У вас немає дозволу на використання цієї команди.',
78
+ [discord_js_1.Locale.Hindi]: 'आपको इस कमांड का उपयोग करने की अनुमति नहीं है।',
79
+ [discord_js_1.Locale.Indonesian]: 'Anda tidak memiliki izin untuk menggunakan perintah ini.',
80
+ [discord_js_1.Locale.Greek]: 'Δεν έχετε άδεια να χρησιμοποιήσετε αυτήν την εντολή.',
81
+ [discord_js_1.Locale.Croatian]: 'Nemate dopuštenje za korištenje ove naredbe.',
82
+ [discord_js_1.Locale.Lithuanian]: 'Jūs neturite teisės naudoti šio komandos.',
83
+ [discord_js_1.Locale.Thai]: 'คุณไม่มีสิทธิ์ใช้คำสั่งนี้.',
84
+ [discord_js_1.Locale.Vietnamese]: 'Bạn không có quyền sử dụng lệnh này.'
85
+ };
86
+ exports.LOCALE_FORBIDDEN = LOCALE_FORBIDDEN;
87
+ /**
88
+ * @description Localization phrases for NSFW command usage errors.
89
+ */
90
+ const LOCALE_NSFW = {
91
+ [discord_js_1.Locale.SpanishLATAM]: 'Este comando solo puede ser usado en canales NSFW.',
92
+ [discord_js_1.Locale.EnglishUS]: 'This command can only be used in NSFW channels.',
93
+ [discord_js_1.Locale.EnglishGB]: 'I do declare, this command is exclusively for channels of a... risqué nature. little bit of cheeky fun, eh?',
94
+ [discord_js_1.Locale.SpanishES]: '¡Ostias, chaval! Que este comando es solo para los canales más guarros, ¿vale? No me seas meapilas.',
95
+ [discord_js_1.Locale.PortugueseBR]: 'Este comando só pode ser usado em canais NSFW.',
96
+ [discord_js_1.Locale.French]: 'Cette commande ne peut être utilisée que dans les salons NSFW.',
97
+ [discord_js_1.Locale.German]: 'Dieser Befehl kann nur in NSFW-Kanälen verwendet werden.',
98
+ [discord_js_1.Locale.Italian]: 'Questo comando può essere utilizzato solo nei canali NSFW.',
99
+ [discord_js_1.Locale.Russian]: 'Эту команду можно использовать только в каналах NSFW.',
100
+ [discord_js_1.Locale.ChineseCN]: '此命令只能在NSFW频道中使用。',
101
+ [discord_js_1.Locale.ChineseTW]: '此命令只能在 NSFW 頻道中使用。',
102
+ [discord_js_1.Locale.Japanese]: 'このコマンドはNSFWチャンネルでのみ使用できます。',
103
+ [discord_js_1.Locale.Korean]: '이 명령어는 NSFW 채널에서만 사용할 수 있습니다.',
104
+ [discord_js_1.Locale.Bulgarian]: 'Тази команда може да се използва само в NSFW канали.',
105
+ [discord_js_1.Locale.Czech]: 'Tento příkaz lze použít pouze v kanálech NSFW.',
106
+ [discord_js_1.Locale.Danish]: 'Denne kommando kan kun bruges i NSFW-kanaler.',
107
+ [discord_js_1.Locale.Dutch]: 'Deze opdracht kan alleen worden gebruikt in NSFW-kanalen.',
108
+ [discord_js_1.Locale.Finnish]: 'Tätä komentoa voi käyttää vain NSFW-kanavilla.',
109
+ [discord_js_1.Locale.Hungarian]: 'Ez a parancs csak NSFW csatornákon használható.',
110
+ [discord_js_1.Locale.Norwegian]: 'Denne kommandoen kan bare brukes i NSFW-kanaler.',
111
+ [discord_js_1.Locale.Polish]: 'Ta komenda może być używana tylko na kanałach NSFW.',
112
+ [discord_js_1.Locale.Romanian]: 'Această comandă poate fi utilizată numai în canalele NSFW.',
113
+ [discord_js_1.Locale.Swedish]: 'Det här kommandot kan endast användas i NSFW-kanaler.',
114
+ [discord_js_1.Locale.Turkish]: 'Bu komut yalnızca NSFW kanallarında kullanılabilir.',
115
+ [discord_js_1.Locale.Ukrainian]: 'Цю команду можна використовувати лише в каналах NSFW.',
116
+ [discord_js_1.Locale.Hindi]: 'यह कमांड केवल NSFW चैनलों में ही उपयोग की जा सकती है।',
117
+ [discord_js_1.Locale.Indonesian]: 'Perintah ini hanya dapat digunakan di saluran NSFW.',
118
+ [discord_js_1.Locale.Greek]: 'Αυτή η εντολή μπορεί να χρησιμοποιηθεί μόνο σε κανάλια NSFW.',
119
+ [discord_js_1.Locale.Croatian]: 'Ova se naredba može koristiti samo u NSFW kanalima.',
120
+ [discord_js_1.Locale.Lithuanian]: 'Ši komanda gali būti naudojama tik NSFW kanaluose.',
121
+ [discord_js_1.Locale.Thai]: 'คำสั่งนี้สามารถใช้ได้เฉพาะในช่องทาง NSFW เท่านั้น.',
122
+ [discord_js_1.Locale.Vietnamese]: 'Lệnh này chỉ có thể được sử dụng trong các kênh NSFW.'
123
+ };
124
+ exports.LOCALE_NSFW = LOCALE_NSFW;
125
+ /**
126
+ * @description Localization phrases for general application errors.
127
+ */
128
+ const LOCALE_ERROR = {
129
+ [discord_js_1.Locale.SpanishLATAM]: 'Ocurrió un error al procesar tu solicitud.',
130
+ [discord_js_1.Locale.EnglishUS]: 'An error occurred while processing your request.',
131
+ [discord_js_1.Locale.EnglishGB]: 'I do declare, an error occurred while processing your request.',
132
+ [discord_js_1.Locale.SpanishES]: 'Pero que me estás contando, willy, ocurrió un error al procesar tu solicitud.',
133
+ [discord_js_1.Locale.PortugueseBR]: 'Ocorreu um erro ao processar sua solicitação.',
134
+ [discord_js_1.Locale.French]: 'Une erreur est survenue lors du traitement de votre demande.',
135
+ [discord_js_1.Locale.German]: 'Bei der Verarbeitung Ihrer Anfrage ist ein Fehler aufgetreten.',
136
+ [discord_js_1.Locale.Italian]: 'Si è verificato un errore durante l\'elaborazione della tua richiesta.',
137
+ [discord_js_1.Locale.Russian]: 'Произошла ошибка при обработке вашего запроса.',
138
+ [discord_js_1.Locale.ChineseCN]: '处理您的请求时发生错误。',
139
+ [discord_js_1.Locale.ChineseTW]: '處理您的請求時發生錯誤。',
140
+ [discord_js_1.Locale.Japanese]: 'リクエストの処理中にエラーが発生しました。',
141
+ [discord_js_1.Locale.Korean]: '요청을 처리하는 동안 오류가 발생했습니다.',
142
+ [discord_js_1.Locale.Bulgarian]: 'При обработката на заявката ви възникна грешка.',
143
+ [discord_js_1.Locale.Czech]: 'Při zpracování vaší žádosti došlo k chybě.',
144
+ [discord_js_1.Locale.Danish]: 'Der opstod en fejl under behandlingen af din anmodning.',
145
+ [discord_js_1.Locale.Dutch]: 'Er is een fout opgetreden bij het verwerken van uw verzoek.',
146
+ [discord_js_1.Locale.Finnish]: 'Pyyntösi käsittelyssä tapahtui virhe.',
147
+ [discord_js_1.Locale.Hungarian]: 'A kérésed feldolgozása során hiba lépett fel.',
148
+ [discord_js_1.Locale.Norwegian]: 'Det oppstod en feil under behandling av forespørselen din.',
149
+ [discord_js_1.Locale.Polish]: 'Wystąpił błąd podczas przetwarzania twojej prośby.',
150
+ [discord_js_1.Locale.Romanian]: 'A apărut o eroare în timpul procesării cererii tale.',
151
+ [discord_js_1.Locale.Swedish]: 'Ett fel inträffade vid behandling av din begäran.',
152
+ [discord_js_1.Locale.Turkish]: 'Talebiniz işlenirken bir hata oluştu.',
153
+ [discord_js_1.Locale.Ukrainian]: 'Під час обробки вашого запиту сталася помилка.',
154
+ [discord_js_1.Locale.Hindi]: 'आपके अनुरोध को संसाधित करते समय एक त्रुटि हुई।',
155
+ [discord_js_1.Locale.Indonesian]: 'Terjadi kesalahan saat memproses permintaan Anda.',
156
+ [discord_js_1.Locale.Greek]: 'Συνέβη σφάλμα κατά την επεξεργασία του αιτήματός σας.',
157
+ [discord_js_1.Locale.Croatian]: 'Došlo je do pogreške prilikom obrade vašeg zahtjeva.',
158
+ [discord_js_1.Locale.Lithuanian]: 'Apdorojant jūsų užklausą įvyko klaida.',
159
+ [discord_js_1.Locale.Thai]: 'เกิดข้อผิดพลาดระหว่างการประมวลผลคำขอของคุณ',
160
+ [discord_js_1.Locale.Vietnamese]: 'Đã xảy ra lỗi trong quá trình xử lý yêu cầu của bạn.'
161
+ };
162
+ exports.LOCALE_ERROR = LOCALE_ERROR;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Contains the structure for creating reusable button components.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { ButtonBuilder, ButtonStyle } from "discord.js";
7
+ import { ButtonExecuteFunction } from "./types";
8
+ /**
9
+ * @class ModularButton
10
+ * @description A class to create and manage reusable button components.
11
+ */
12
+ export default class ModularButton {
13
+ /** The Discord.js ButtonBuilder instance. */
14
+ buttonObject: ButtonBuilder;
15
+ /** The custom ID for the button, used to identify it in interactions. */
16
+ customId: string;
17
+ /** The visual style of the button. */
18
+ style: ButtonStyle;
19
+ /** The function to execute when the button is clicked. */
20
+ execute: ButtonExecuteFunction;
21
+ /**
22
+ * @description Creates a new ModularButton instance.
23
+ * @param {string} customId The custom ID for the button. This should be unique within the context of a message.
24
+ * @param {ButtonStyle} style The visual style of the button.
25
+ */
26
+ constructor(customId: string, style: ButtonStyle);
27
+ /**
28
+ * @description Sets the execution function for the button's click event.
29
+ * @param {ButtonExecuteFunction} executeFunction The function to run when the button is interacted with.
30
+ * @returns {this} The current ModularButton instance for method chaining.
31
+ */
32
+ setExecute(executeFunction: ButtonExecuteFunction): this;
33
+ }