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.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @module ModularLocale
3
+ * @description Generic localization phrases used throughout the application.
4
+ * @license MIT
5
+ */
6
+ import { Locale } from "discord.js";
7
+ /**
8
+ * @description Class to handle localization in a modular way.
9
+ */
10
+ declare class ModularLocale {
11
+ locale: Locale;
12
+ phrases: Record<string, string>;
13
+ seconds: Record<string, string>;
14
+ minutes: Record<string, string>;
15
+ constructor(locale: Locale);
16
+ /**
17
+ * Set the singular and plural forms for seconds.
18
+ * @param {string} singular The singular form (e.g., '{s} segundo').
19
+ * @param {string} plural The plural form (e.g., '{s} segundos').
20
+ * @returns {ModularLocale}
21
+ */
22
+ setSeconds(singular: string, plural: string): this;
23
+ /**
24
+ * Set the singular and plural forms for minutes.
25
+ * @param {string} singular The singular form (e.g., '{m} minuto').
26
+ * @param {string} plural The plural form (e.g., '{m} minutos').
27
+ * @returns {ModularLocale}
28
+ */
29
+ setMinutes(singular: string, plural: string): this;
30
+ /**
31
+ * Set the main phrase for the command delay.
32
+ * @param {string} phrase The phrase when only seconds or minutes are present.
33
+ * @returns {ModularLocale}
34
+ */
35
+ setPhrase(phrase: string): this;
36
+ /**
37
+ * Set the phrase when both seconds and minutes are present.
38
+ * @param {string} phrase The phrase for combined time.
39
+ * @returns {ModularLocale}
40
+ */
41
+ setPhrasePlural(phrase: string): this;
42
+ /**
43
+ * Set the phrase when only minutes are present.
44
+ * @param {string} phrase The phrase for when only minutes are present.
45
+ * @returns {ModularLocale}
46
+ */
47
+ setPhraseOnlyMinutes(phrase: string): this;
48
+ getPhrase: () => Record<string, string>;
49
+ getSeconds: () => Record<string, string>;
50
+ getMinutes: () => Record<string, string>;
51
+ /**
52
+ * Get the formatted phrase based on the time.
53
+ * @param {number} time The time in seconds.
54
+ * @returns {string} The formatted string.
55
+ */
56
+ formatTime(time: number): string;
57
+ }
58
+ /**
59
+ * @description Localization phrases for delay commands in ModularLocale structure.
60
+ * @example ```js
61
+ * const phrase = LOCALE_DELAY[Locale.EnglishUS];
62
+ * console.log( phrase.formatTime(64) ); // 'You must wait 4 seconds and 1 minute.'
63
+ * console.log( phrase.formatTime(390) ); // 'You must wait 30 seconds and 6 minutes.'
64
+ * console.log( phrase.formatTime(1) ); // 'You must wait 1 second.'
65
+ * console.log( phrase.formatTime(120) ); // 'You must wait 2 minutes.'
66
+ * ```
67
+ */
68
+ declare const LOCALE_DELAY: {
69
+ "es-419": ModularLocale;
70
+ "en-US": ModularLocale;
71
+ "en-GB": ModularLocale;
72
+ "es-ES": ModularLocale;
73
+ "pt-BR": ModularLocale;
74
+ fr: ModularLocale;
75
+ de: ModularLocale;
76
+ it: ModularLocale;
77
+ ru: ModularLocale;
78
+ "zh-CN": ModularLocale;
79
+ "zh-TW": ModularLocale;
80
+ ja: ModularLocale;
81
+ ko: ModularLocale;
82
+ bg: ModularLocale;
83
+ cs: ModularLocale;
84
+ da: ModularLocale;
85
+ nl: ModularLocale;
86
+ fi: ModularLocale;
87
+ hu: ModularLocale;
88
+ no: ModularLocale;
89
+ pl: ModularLocale;
90
+ ro: ModularLocale;
91
+ "sv-SE": ModularLocale;
92
+ tr: ModularLocale;
93
+ uk: ModularLocale;
94
+ hi: ModularLocale;
95
+ id: ModularLocale;
96
+ el: ModularLocale;
97
+ hr: ModularLocale;
98
+ lt: ModularLocale;
99
+ th: ModularLocale;
100
+ vi: ModularLocale;
101
+ };
102
+ export default LOCALE_DELAY;
103
+ export { LOCALE_DELAY, ModularLocale };
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ /**
3
+ * @module ModularLocale
4
+ * @description Generic localization phrases used throughout the application.
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ModularLocale = exports.LOCALE_DELAY = void 0;
9
+ const discord_js_1 = require("discord.js");
10
+ /**
11
+ * Format a time unit (seconds or minutes) for localization.
12
+ * @param unit The time unit ('s' for seconds, 'm' for minutes).
13
+ * @param unitCount The count of the time unit.
14
+ * @param unitData The localization data for the time unit.
15
+ * @returns The formatted string for the time unit.
16
+ */
17
+ function formatUnit(unit, unitCount, unitData) {
18
+ if (unitCount === 1) {
19
+ return unitData.singular.replace(`{${unit}}`, unitCount.toString());
20
+ }
21
+ else {
22
+ return unitData.plural.replace(`{${unit}}`, unitCount.toString());
23
+ }
24
+ }
25
+ ;
26
+ /**
27
+ * @description Class to handle localization in a modular way.
28
+ */
29
+ class ModularLocale {
30
+ constructor(locale) {
31
+ this.getPhrase = () => this.phrases;
32
+ this.getSeconds = () => this.seconds;
33
+ this.getMinutes = () => this.minutes;
34
+ this.locale = locale;
35
+ this.phrases = {};
36
+ this.seconds = {};
37
+ this.minutes = {};
38
+ }
39
+ /**
40
+ * Set the singular and plural forms for seconds.
41
+ * @param {string} singular The singular form (e.g., '{s} segundo').
42
+ * @param {string} plural The plural form (e.g., '{s} segundos').
43
+ * @returns {ModularLocale}
44
+ */
45
+ setSeconds(singular, plural) {
46
+ this.seconds = { singular, plural };
47
+ return this;
48
+ }
49
+ /**
50
+ * Set the singular and plural forms for minutes.
51
+ * @param {string} singular The singular form (e.g., '{m} minuto').
52
+ * @param {string} plural The plural form (e.g., '{m} minutos').
53
+ * @returns {ModularLocale}
54
+ */
55
+ setMinutes(singular, plural) {
56
+ this.minutes = { singular, plural };
57
+ return this;
58
+ }
59
+ /**
60
+ * Set the main phrase for the command delay.
61
+ * @param {string} phrase The phrase when only seconds or minutes are present.
62
+ * @returns {ModularLocale}
63
+ */
64
+ setPhrase(phrase) {
65
+ this.phrases.singular = phrase;
66
+ return this;
67
+ }
68
+ /**
69
+ * Set the phrase when both seconds and minutes are present.
70
+ * @param {string} phrase The phrase for combined time.
71
+ * @returns {ModularLocale}
72
+ */
73
+ setPhrasePlural(phrase) {
74
+ this.phrases.plural = phrase;
75
+ return this;
76
+ }
77
+ /**
78
+ * Set the phrase when only minutes are present.
79
+ * @param {string} phrase The phrase for when only minutes are present.
80
+ * @returns {ModularLocale}
81
+ */
82
+ setPhraseOnlyMinutes(phrase) {
83
+ this.phrases.onlyMinutes = phrase;
84
+ return this;
85
+ }
86
+ /**
87
+ * Get the formatted phrase based on the time.
88
+ * @param {number} time The time in seconds.
89
+ * @returns {string} The formatted string.
90
+ */
91
+ formatTime(time) {
92
+ const minutes = Math.floor(time / 60);
93
+ const seconds = time % 60;
94
+ let formattedPhrase = '';
95
+ if (minutes > 0 && seconds > 0) {
96
+ formattedPhrase = this.phrases.plural
97
+ .replace('{seconds}', formatUnit('s', seconds, this.seconds))
98
+ .replace('{minutes}', formatUnit('m', minutes, this.minutes));
99
+ }
100
+ else if (minutes > 0 && seconds === 0) {
101
+ // Handle case where only minutes are present
102
+ formattedPhrase = this.phrases.onlyMinutes
103
+ .replace('{minutes}', formatUnit('m', minutes, this.minutes));
104
+ }
105
+ else {
106
+ formattedPhrase = this.phrases.singular
107
+ .replace('{seconds}', formatUnit('s', seconds, this.seconds))
108
+ .replace('{minutes}', '')
109
+ .trim();
110
+ }
111
+ return formattedPhrase.replace(/\s+/g, ' ').trim();
112
+ }
113
+ }
114
+ exports.ModularLocale = ModularLocale;
115
+ /**
116
+ * @description Localization phrases for delay commands in ModularLocale structure.
117
+ * @example ```js
118
+ * const phrase = LOCALE_DELAY[Locale.EnglishUS];
119
+ * console.log( phrase.formatTime(64) ); // 'You must wait 4 seconds and 1 minute.'
120
+ * console.log( phrase.formatTime(390) ); // 'You must wait 30 seconds and 6 minutes.'
121
+ * console.log( phrase.formatTime(1) ); // 'You must wait 1 second.'
122
+ * console.log( phrase.formatTime(120) ); // 'You must wait 2 minutes.'
123
+ * ```
124
+ */
125
+ const LOCALE_DELAY = {
126
+ [discord_js_1.Locale.SpanishLATAM]: new ModularLocale(discord_js_1.Locale.SpanishLATAM)
127
+ .setSeconds('{s} segundo', '{s} segundos')
128
+ .setMinutes('{m} minuto', '{m} minutos')
129
+ .setPhrase('Debes esperar {seconds} antes de utilizar este comando denuevo.')
130
+ .setPhrasePlural('Debes esperar {seconds} y {minutes} antes de utilizar este comando denuevo.')
131
+ .setPhraseOnlyMinutes('Debes esperar {minutes} antes de utilizar este comando denuevo.'),
132
+ [discord_js_1.Locale.EnglishUS]: new ModularLocale(discord_js_1.Locale.EnglishUS)
133
+ .setSeconds('{s} second', '{s} seconds')
134
+ .setMinutes('{m} minute', '{m} minutes')
135
+ .setPhrase('You must wait {seconds} before using this command again.')
136
+ .setPhrasePlural('You must wait {seconds} and {minutes} before using this command again.')
137
+ .setPhraseOnlyMinutes('You must wait {minutes} before using this command again.'),
138
+ [discord_js_1.Locale.EnglishGB]: new ModularLocale(discord_js_1.Locale.EnglishGB)
139
+ .setSeconds('{s} second', '{s} seconds')
140
+ .setMinutes('{m} minute', '{m} minutes')
141
+ .setPhrase('One must exhibit a spot of patience, you see. A brief pause of {seconds} is required before another attempt, what?')
142
+ .setPhrasePlural('One must exhibit a spot of patience, you see. A brief pause of {seconds} and {minutes} is required before another attempt, what?')
143
+ .setPhraseOnlyMinutes('One must exhibit a spot of patience, you see. A brief pause of {minutes} is required before another attempt, what?'),
144
+ [discord_js_1.Locale.SpanishES]: new ModularLocale(discord_js_1.Locale.SpanishES)
145
+ .setSeconds('{s} segundo', '{s} segundos')
146
+ .setMinutes('{m} minuto', '{m} minutos')
147
+ .setPhrase('¡Joder, tío! ¡Que te esperes {seconds} antes de utilizar este comando, coño!')
148
+ .setPhrasePlural('¡Joder, tío! ¡Que te esperes {seconds} y {minutes}, coño!')
149
+ .setPhraseOnlyMinutes('¡Joder, tío! ¡Que te esperes {minutes} antes de utilizar este comando, coño!'),
150
+ [discord_js_1.Locale.PortugueseBR]: new ModularLocale(discord_js_1.Locale.PortugueseBR)
151
+ .setSeconds('{s} segundo', '{s} segundos')
152
+ .setMinutes('{m} minuto', '{m} minutos')
153
+ .setPhrase('Você deve esperar {seconds} antes de usar este comando novamente.')
154
+ .setPhrasePlural('Você deve esperar {seconds} e {minutes} antes de usar este comando novamente.')
155
+ .setPhraseOnlyMinutes('Você deve esperar {minutes} antes de usar este comando novamente.'),
156
+ [discord_js_1.Locale.French]: new ModularLocale(discord_js_1.Locale.French)
157
+ .setSeconds('{s} seconde', '{s} secondes')
158
+ .setMinutes('{m} minute', '{m} minutes')
159
+ .setPhrase('Vous devez attendre {seconds} avant d\'utiliser cette commande à nouveau.')
160
+ .setPhrasePlural('Vous devez attendre {seconds} et {minutes} avant d\'utiliser cette commande à nouveau.')
161
+ .setPhraseOnlyMinutes('Vous devez attendre {minutes} avant d\'utiliser cette commande à nouveau.'),
162
+ [discord_js_1.Locale.German]: new ModularLocale(discord_js_1.Locale.German)
163
+ .setSeconds('{s} Sekunde', '{s} Sekunden')
164
+ .setMinutes('{m} Minute', '{m} Minuten')
165
+ .setPhrase('Sie müssen {seconds} warten, bevor Sie diesen Befehl erneut verwenden können.')
166
+ .setPhrasePlural('Sie müssen {seconds} und {minutes} warten, bevor Sie diesen Befehl erneut verwenden können.')
167
+ .setPhraseOnlyMinutes('Sie müssen {minutes} warten, bevor Sie diesen Befehl erneut verwenden können.'),
168
+ [discord_js_1.Locale.Italian]: new ModularLocale(discord_js_1.Locale.Italian)
169
+ .setSeconds('{s} secondo', '{s} secondi')
170
+ .setMinutes('{m} minuto', '{m} minuti')
171
+ .setPhrase('Devi aspettare {seconds} prima di utilizzare di nuovo questo comando.')
172
+ .setPhrasePlural('Devi aspettare {seconds} e {minutes} prima di utilizzare di nuovo questo comando.')
173
+ .setPhraseOnlyMinutes('Devi aspettare {minutes} prima di utilizzare di nuovo questo comando.'),
174
+ [discord_js_1.Locale.Russian]: new ModularLocale(discord_js_1.Locale.Russian)
175
+ .setSeconds('{s} секунду', '{s} секунд')
176
+ .setMinutes('{m} минуту', '{m} минут')
177
+ .setPhrase('Вы должны подождать {seconds} перед повторным использованием этой команды.')
178
+ .setPhrasePlural('Вы должны подождать {seconds} и {minutes} перед повторным использованием этой команды.')
179
+ .setPhraseOnlyMinutes('Вы должны подождать {minutes} перед повторным использованием этой команды.'),
180
+ [discord_js_1.Locale.ChineseCN]: new ModularLocale(discord_js_1.Locale.ChineseCN)
181
+ .setSeconds('{s} 秒', '{s} 秒')
182
+ .setMinutes('{m} 分钟', '{m} 分钟')
183
+ .setPhrase('您必须等待 {seconds} 才能再次使用此命令.')
184
+ .setPhrasePlural('您必须等待 {seconds} 和 {minutes} 才能再次使用此命令.')
185
+ .setPhraseOnlyMinutes('您必须等待 {minutes} 才能再次使用此命令.'),
186
+ [discord_js_1.Locale.ChineseTW]: new ModularLocale(discord_js_1.Locale.ChineseTW)
187
+ .setSeconds('{s} 秒', '{s} 秒')
188
+ .setMinutes('{m} 分鐘', '{m} 分鐘')
189
+ .setPhrase('您必須等待 {seconds} 才能再次使用此命令.')
190
+ .setPhrasePlural('您必須等待 {seconds} 和 {minutes} 才能再次使用此命令.')
191
+ .setPhraseOnlyMinutes('您必須等待 {minutes} 才能再次使用此命令.'),
192
+ [discord_js_1.Locale.Japanese]: new ModularLocale(discord_js_1.Locale.Japanese)
193
+ .setSeconds('{s} 秒', '{s} 秒')
194
+ .setMinutes('{m} 分', '{m} 分')
195
+ .setPhrase('このコマンドを再度使用するには、{seconds} 待つ必要があります.')
196
+ .setPhrasePlural('このコマンドを再度使用するには、{seconds} と {minutes} 待つ必要があります.')
197
+ .setPhraseOnlyMinutes('このコマンドを再度使用するには、{minutes} 待つ必要があります.'),
198
+ [discord_js_1.Locale.Korean]: new ModularLocale(discord_js_1.Locale.Korean)
199
+ .setSeconds('{s} 초', '{s} 초')
200
+ .setMinutes('{m} 분', '{m} 분')
201
+ .setPhrase('이 명령어를 다시 사용하려면 {seconds} 기다려야 합니다.')
202
+ .setPhrasePlural('이 명령어를 다시 사용하려면 {seconds} 하고 {minutes} 기다려야 합니다.')
203
+ .setPhraseOnlyMinutes('이 명령어를 다시 사용하려면 {minutes} 기다려야 합니다.'),
204
+ [discord_js_1.Locale.Bulgarian]: new ModularLocale(discord_js_1.Locale.Bulgarian)
205
+ .setSeconds('{s} секунд', '{s} секунди')
206
+ .setMinutes('{m} минут', '{m} минути')
207
+ .setPhrase('Трябва да изчакате {seconds} преди да използвате тази команда отново.')
208
+ .setPhrasePlural('Трябва да изчакате {seconds} и {minutes} преди да използвате тази команда отново.')
209
+ .setPhraseOnlyMinutes('Трябва да изчакате {minutes} преди да използвате тази команда отново.'),
210
+ [discord_js_1.Locale.Czech]: new ModularLocale(discord_js_1.Locale.Czech)
211
+ .setSeconds('{s} sekundu', '{s} sekund')
212
+ .setMinutes('{m} minutu', '{m} minut')
213
+ .setPhrase('Musíte počkat {seconds} než znovu použijete tento příkaz.')
214
+ .setPhrasePlural('Musíte počkat {seconds} a {minutes} než znovu použijete tento příkaz.')
215
+ .setPhraseOnlyMinutes('Musíte počkat {minutes} než znovu použijete tento příkaz.'),
216
+ [discord_js_1.Locale.Danish]: new ModularLocale(discord_js_1.Locale.Danish)
217
+ .setSeconds('{s} sekund', '{s} sekunder')
218
+ .setMinutes('{m} minut', '{m} minutter')
219
+ .setPhrase('Du skal vente {seconds} før du kan bruge denne kommando igen.')
220
+ .setPhrasePlural('Du skal vente {seconds} og {minutes} før du kan bruge denne kommando igen.')
221
+ .setPhraseOnlyMinutes('Du skal vente {minutes} før du kan bruge denne kommando igen.'),
222
+ [discord_js_1.Locale.Dutch]: new ModularLocale(discord_js_1.Locale.Dutch)
223
+ .setSeconds('{s} seconde', '{s} seconden')
224
+ .setMinutes('{m} minuut', '{m} minuten')
225
+ .setPhrase('Je moet {seconds} wachten voordat je dit commando opnieuw kunt gebruiken.')
226
+ .setPhrasePlural('Je moet {seconds} en {minutes} wachten voordat je dit commando opnieuw kunt gebruiken.')
227
+ .setPhraseOnlyMinutes('Je moet {minutes} wachten voordat je dit commando opnieuw kunt gebruiken.'),
228
+ [discord_js_1.Locale.Finnish]: new ModularLocale(discord_js_1.Locale.Finnish)
229
+ .setSeconds('{s} sekunti', '{s} sekuntia')
230
+ .setMinutes('{m} minuutti', '{m} minuuttia')
231
+ .setPhrase('Sinun on odotettava {seconds} ennen kuin voit käyttää tätä komentoa uudelleen.')
232
+ .setPhrasePlural('Sinun on odotettava {seconds} ja {minutes} ennen kuin voit käyttää tätä komentoa uudelleen.')
233
+ .setPhraseOnlyMinutes('Sinun on odotettava {minutes} ennen kuin voit käyttää tätä komentoa uudelleen.'),
234
+ [discord_js_1.Locale.Hungarian]: new ModularLocale(discord_js_1.Locale.Hungarian)
235
+ .setSeconds('{s} másodperc', '{s} másodpercet')
236
+ .setMinutes('{m} perc', '{m} percet')
237
+ .setPhrase('Várnod kell {seconds} mielőtt újra használhatod ezt a parancsot.')
238
+ .setPhrasePlural('Várnod kell {seconds} és {minutes} mielőtt újra használhatod ezt a parancsot.')
239
+ .setPhraseOnlyMinutes('Várnod kell {minutes} mielőtt újra használhatod ezt a parancsot.'),
240
+ [discord_js_1.Locale.Norwegian]: new ModularLocale(discord_js_1.Locale.Norwegian)
241
+ .setSeconds('{s} sekund', '{s} sekunder')
242
+ .setMinutes('{m} minutt', '{m} minutter')
243
+ .setPhrase('Du må vente {seconds} før du kan bruke denne kommandoen igjen.')
244
+ .setPhrasePlural('Du må vente {seconds} og {minutes} før du kan bruke denne kommandoen igjen.')
245
+ .setPhraseOnlyMinutes('Du må vente {minutes} før du kan bruke denne kommandoen igjen.'),
246
+ [discord_js_1.Locale.Polish]: new ModularLocale(discord_js_1.Locale.Polish)
247
+ .setSeconds('{s} sekundę', '{s} sekundy')
248
+ .setMinutes('{m} minutę', '{m} minuty')
249
+ .setPhrase('Musisz poczekać {seconds} zanim ponownie użyjesz tego polecenia.')
250
+ .setPhrasePlural('Musisz poczekać {seconds} i {minutes} zanim ponownie użyjesz tego polecenia.')
251
+ .setPhraseOnlyMinutes('Musisz poczekać {minutes} zanim ponownie użyjesz tego polecenia.'),
252
+ [discord_js_1.Locale.Romanian]: new ModularLocale(discord_js_1.Locale.Romanian)
253
+ .setSeconds('{s} secundă', '{s} secunde')
254
+ .setMinutes('{m} minut', '{m} minute')
255
+ .setPhrase('Trebuie să aștepți {seconds} înainte de a folosi din nou acest comandă.')
256
+ .setPhrasePlural('Trebuie să aștepți {seconds} și {minutes} înainte de a folosi din nou acest comandă.')
257
+ .setPhraseOnlyMinutes('Trebuie să aștepți {minutes} înainte de a folosi din nou acest comandă.'),
258
+ [discord_js_1.Locale.Swedish]: new ModularLocale(discord_js_1.Locale.Swedish)
259
+ .setSeconds('{s} sekund', '{s} sekunder')
260
+ .setMinutes('{m} minut', '{m} minuter')
261
+ .setPhrase('Du måste vänta {seconds} innan du kan använda det här kommandot igen.')
262
+ .setPhrasePlural('Du måste vänta {seconds} och {minutes} innan du kan använda det här kommandot igen.')
263
+ .setPhraseOnlyMinutes('Du måste vänta {minutes} innan du kan använda det här kommandot igen.'),
264
+ [discord_js_1.Locale.Turkish]: new ModularLocale(discord_js_1.Locale.Turkish)
265
+ .setSeconds('{s} saniye', '{s} saniye')
266
+ .setMinutes('{m} dakika', '{m} dakika')
267
+ .setPhrase('Bu komutu tekrar kullanmadan önce {seconds} beklemeniz gerekir.')
268
+ .setPhrasePlural('Bu komutu tekrar kullanmadan önce {seconds} ve {minutes} beklemeniz gerekir.')
269
+ .setPhraseOnlyMinutes('Bu komutu tekrar kullanmadan önce {minutes} beklemeniz gerekir.'),
270
+ [discord_js_1.Locale.Ukrainian]: new ModularLocale(discord_js_1.Locale.Ukrainian)
271
+ .setSeconds('{s} секунду', '{s} секунди')
272
+ .setMinutes('{m} хвилину', '{m} хвилини')
273
+ .setPhrase('Вам потрібно почекати {seconds} перш ніж знову використовувати цю команду.')
274
+ .setPhrasePlural('Вам потрібно почекати {seconds} і {minutes} перш ніж знову використовувати цю команду.')
275
+ .setPhraseOnlyMinutes('Вам потрібно почекати {minutes} перш ніж знову використовувати цю команду.'),
276
+ [discord_js_1.Locale.Hindi]: new ModularLocale(discord_js_1.Locale.Hindi)
277
+ .setSeconds('{s} सेकंड', '{s} सेकंड')
278
+ .setMinutes('{m} मिनट', '{m} मिनट')
279
+ .setPhrase('आपको इस कमांड का उपयोग करने से पहले {seconds} इंतजार करना होगा.')
280
+ .setPhrasePlural('आपको इस कमांड का उपयोग करने से पहले {seconds} और {minutes} इंतजार करना होगा.')
281
+ .setPhraseOnlyMinutes('आपको इस कमांड का उपयोग करने से पहले {minutes} इंतजार करना होगा.'),
282
+ [discord_js_1.Locale.Indonesian]: new ModularLocale(discord_js_1.Locale.Indonesian)
283
+ .setSeconds('{s} detik', '{s} detik')
284
+ .setMinutes('{m} menit', '{m} menit')
285
+ .setPhrase('Anda harus menunggu {seconds} sebelum menggunakan perintah ini lagi.')
286
+ .setPhrasePlural('Anda harus menunggu {seconds} dan {minutes} sebelum menggunakan perintah ini lagi.')
287
+ .setPhraseOnlyMinutes('Anda harus menunggu {minutes} sebelum menggunakan perintah ini lagi.'),
288
+ [discord_js_1.Locale.Greek]: new ModularLocale(discord_js_1.Locale.Greek)
289
+ .setSeconds('{s} δευτερόλεπτο', '{s} δευτερόλεπτα')
290
+ .setMinutes('{m} λεπτό', '{m} λεπτά')
291
+ .setPhrase('Πρέπει να περιμένετε {seconds} πριν χρησιμοποιήσετε ξανά αυτήν την εντολή.')
292
+ .setPhrasePlural('Πρέπει να περιμένετε {seconds} και {minutes} πριν χρησιμοποιήσετε ξανά αυτήν την εντολή.')
293
+ .setPhraseOnlyMinutes('Πρέπει να περιμένετε {minutes} πριν χρησιμοποιήσετε ξανά αυτήν την εντολή.'),
294
+ [discord_js_1.Locale.Croatian]: new ModularLocale(discord_js_1.Locale.Croatian)
295
+ .setSeconds('{s} sekundu', '{s} sekunde')
296
+ .setMinutes('{m} minutu', '{m} minute')
297
+ .setPhrase('Morate pričekati {seconds} prije nego što ponovno upotrijebite ovu naredbu.')
298
+ .setPhrasePlural('Morate pričekati {seconds} i {minutes} prije nego što ponovno upotrijebite ovu naredbu.')
299
+ .setPhraseOnlyMinutes('Morate pričekati {minutes} prije nego što ponovno upotrijebite ovu naredbu.'),
300
+ [discord_js_1.Locale.Lithuanian]: new ModularLocale(discord_js_1.Locale.Lithuanian)
301
+ .setSeconds('{s} sekundę', '{s} sekundes')
302
+ .setMinutes('{m} minutę', '{m} minutes')
303
+ .setPhrase('Prieš vėl naudodamiesi šiuo komandu, turite palaukti {seconds}.')
304
+ .setPhrasePlural('Prieš vėl naudodamiesi šiuo komandu, turite palaukti {seconds} ir {minutes}.')
305
+ .setPhraseOnlyMinutes('Prieš vėl naudodamiesi šiuo komandu, turite palaukti {minutes}.'),
306
+ [discord_js_1.Locale.Thai]: new ModularLocale(discord_js_1.Locale.Thai)
307
+ .setSeconds('{s} วินาที', '{s} วินาที')
308
+ .setMinutes('{m} นาที', '{m} นาที')
309
+ .setPhrase('คุณต้องรอ {seconds} ก่อนที่จะใช้คำสั่งนี้อีกครั้ง')
310
+ .setPhrasePlural('คุณต้องรอ {seconds} และ {minutes} ก่อนที่จะใช้คำสั่งนี้อีกครั้ง')
311
+ .setPhraseOnlyMinutes('คุณต้องรอ {minutes} ก่อนที่จะใช้คำสั่งนี้อีกครั้ง'),
312
+ [discord_js_1.Locale.Vietnamese]: new ModularLocale(discord_js_1.Locale.Vietnamese)
313
+ .setSeconds('{s} giây', '{s} giây')
314
+ .setMinutes('{m} phút', '{m} phút')
315
+ .setPhrase('Bạn phải đợi {seconds} trước khi sử dụng lại lệnh này.')
316
+ .setPhrasePlural('Bạn phải đợi {seconds} và {minutes} trước khi sử dụng lại lệnh này.')
317
+ .setPhraseOnlyMinutes('Bạn phải đợi {minutes} trước khi sử dụng lại lệnh này.')
318
+ };
319
+ exports.LOCALE_DELAY = LOCALE_DELAY;
320
+ exports.default = LOCALE_DELAY;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @file Contains the structure and logic for creating modular modals.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
7
+ import { LocaleKey, ModalExecuteFunction } from "./types";
8
+ import ModularCommand from "./modularcommand";
9
+ /**
10
+ * @class ModularModal
11
+ * @description Represents a modular modal that can be dynamically created and managed.
12
+ */
13
+ export default class ModularModal {
14
+ /** The Discord.js ModalBuilder instance. */
15
+ modalObject: ModalBuilder;
16
+ /** The unique custom ID for the modal, formatted as `${command.name}_${modalId}`. */
17
+ customId: string;
18
+ /** The base ID for the modal, used for localization. */
19
+ modalId: string;
20
+ /** A map to store the text input components of the modal. */
21
+ modalInputs: Map<string, TextInputBuilder>;
22
+ /** The command instance to which this modal belongs. */
23
+ command: ModularCommand;
24
+ /** The function to execute when the modal is submitted. */
25
+ execute: ModalExecuteFunction;
26
+ /**
27
+ * @description Creates a new ModularModal instance.
28
+ * @param {string} modalId The base ID for the modal.
29
+ * @param {ModularCommand} command The command that this modal is associated with.
30
+ */
31
+ constructor(modalId: string, command: ModularCommand);
32
+ /**
33
+ * @description Sets the execution function for the modal's submission event.
34
+ * @param {ModalExecuteFunction} executeFunction The function to run when the modal is submitted.
35
+ * @returns {this} The current ModularModal instance for method chaining.
36
+ */
37
+ setExecute(executeFunction: ModalExecuteFunction): this;
38
+ /**
39
+ * @description Creates a new text input component and adds it to the modal.
40
+ * @param {string} id The custom ID for the text input.
41
+ * @param {TextInputStyle} style The visual style of the text input.
42
+ * @returns {TextInputBuilder} The created text input instance.
43
+ */
44
+ newTextInput(id: string, style: TextInputStyle): TextInputBuilder;
45
+ /**
46
+ * @description Builds the final modal object, applying localized titles and labels.
47
+ * @param {LocaleKey} locale The localization object containing translated texts.
48
+ * @returns {ModalBuilder} The fully constructed modal object ready to be sent to a user.
49
+ */
50
+ build(locale: LocaleKey): ModalBuilder;
51
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * @file Contains the structure and logic for creating modular modals.
4
+ * @author vicentefelipechile
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const discord_js_1 = require("discord.js");
9
+ // =================================================================================================
10
+ // Main Class
11
+ // =================================================================================================
12
+ /**
13
+ * @class ModularModal
14
+ * @description Represents a modular modal that can be dynamically created and managed.
15
+ */
16
+ class ModularModal {
17
+ /**
18
+ * @description Creates a new ModularModal instance.
19
+ * @param {string} modalId The base ID for the modal.
20
+ * @param {ModularCommand} command The command that this modal is associated with.
21
+ */
22
+ constructor(modalId, command) {
23
+ /** The function to execute when the modal is submitted. */
24
+ this.execute = async () => { };
25
+ this.customId = `${command.name}_${modalId}`;
26
+ this.modalId = modalId;
27
+ this.command = command;
28
+ this.modalObject = new discord_js_1.ModalBuilder().setCustomId(this.customId);
29
+ this.modalInputs = new Map();
30
+ }
31
+ /**
32
+ * @description Sets the execution function for the modal's submission event.
33
+ * @param {ModalExecuteFunction} executeFunction The function to run when the modal is submitted.
34
+ * @returns {this} The current ModularModal instance for method chaining.
35
+ */
36
+ setExecute(executeFunction) {
37
+ this.execute = executeFunction;
38
+ return this;
39
+ }
40
+ /**
41
+ * @description Creates a new text input component and adds it to the modal.
42
+ * @param {string} id The custom ID for the text input.
43
+ * @param {TextInputStyle} style The visual style of the text input.
44
+ * @returns {TextInputBuilder} The created text input instance.
45
+ */
46
+ newTextInput(id, style) {
47
+ const textInput = new discord_js_1.TextInputBuilder()
48
+ .setCustomId(id)
49
+ .setStyle(style);
50
+ this.modalInputs.set(id, textInput);
51
+ const actionRow = new discord_js_1.ActionRowBuilder().addComponents(textInput);
52
+ this.modalObject.addComponents(actionRow);
53
+ return textInput;
54
+ }
55
+ /**
56
+ * @description Builds the final modal object, applying localized titles and labels.
57
+ * @param {LocaleKey} locale The localization object containing translated texts.
58
+ * @returns {ModalBuilder} The fully constructed modal object ready to be sent to a user.
59
+ */
60
+ build(locale) {
61
+ this.modalObject.setTitle(locale[`${this.command.name}.${this.modalId}.title`]);
62
+ this.modalInputs.forEach((input, id) => {
63
+ const labelKey = `${this.command.name}.${id}.label`;
64
+ const placeholderKey = `${this.command.name}.${id}.placeholder`;
65
+ if (locale[labelKey]) {
66
+ input.setLabel(locale[labelKey]);
67
+ }
68
+ if (locale[placeholderKey]) {
69
+ input.setPlaceholder(locale[placeholderKey]);
70
+ }
71
+ });
72
+ return this.modalObject;
73
+ }
74
+ }
75
+ exports.default = ModularModal;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file Contains the logic for registering modular commands and building their Discord.js data structures.
3
+ * @author vicentefelipechile
4
+ * @license MIT
5
+ */
6
+ import { CommandData } from "./types";
7
+ import ModularCommand from "./modularcommand";
8
+ /**
9
+ * @description Registers an array of modular commands, building their final `CommandData` objects.
10
+ * This function processes the command definitions, sets up command builders, and assigns the execution logic.
11
+ * @param {ModularCommand[]} commands An array of ModularCommand instances.
12
+ * @returns {CommandData[]} An array of command data objects ready for the Discord.js client.
13
+ */
14
+ export default function RegisterCommand(commands: ModularCommand[]): CommandData[];