@open-discord-bots/framework 0.2.17 → 0.3.1
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/dist/api/index.d.ts +16 -15
- package/dist/api/index.js +16 -15
- package/dist/api/main.d.ts +31 -23
- package/dist/api/main.js +3 -1
- package/dist/api/modules/action.d.ts +2 -2
- package/dist/api/modules/action.js +1 -5
- package/dist/api/modules/base.d.ts +29 -11
- package/dist/api/modules/base.js +78 -80
- package/dist/api/modules/builder.d.ts +2 -11
- package/dist/api/modules/builder.js +0 -4
- package/dist/api/modules/checker.d.ts +28 -7
- package/dist/api/modules/checker.js +33 -37
- package/dist/api/modules/client.d.ts +66 -14
- package/dist/api/modules/client.js +146 -132
- package/dist/api/modules/component.d.ts +928 -0
- package/dist/api/modules/component.js +1346 -0
- package/dist/api/modules/config.d.ts +30 -2
- package/dist/api/modules/config.js +90 -7
- package/dist/api/modules/console.d.ts +16 -4
- package/dist/api/modules/console.js +25 -25
- package/dist/api/modules/cooldown.d.ts +5 -5
- package/dist/api/modules/cooldown.js +1 -17
- package/dist/api/modules/database.d.ts +21 -13
- package/dist/api/modules/database.js +0 -23
- package/dist/api/modules/event.d.ts +4 -2
- package/dist/api/modules/event.js +8 -10
- package/dist/api/modules/fuse.d.ts +1 -1
- package/dist/api/modules/helpmenu.d.ts +11 -9
- package/dist/api/modules/helpmenu.js +24 -22
- package/dist/api/modules/language.d.ts +4 -3
- package/dist/api/modules/language.js +9 -16
- package/dist/api/modules/permission.d.ts +10 -1
- package/dist/api/modules/permission.js +17 -20
- package/dist/api/modules/plugin.d.ts +2 -1
- package/dist/api/modules/plugin.js +2 -2
- package/dist/api/modules/post.d.ts +12 -4
- package/dist/api/modules/post.js +36 -10
- package/dist/api/modules/progressbar.d.ts +18 -6
- package/dist/api/modules/progressbar.js +35 -35
- package/dist/api/modules/responder.d.ts +97 -28
- package/dist/api/modules/responder.js +213 -176
- package/dist/api/modules/session.d.ts +11 -2
- package/dist/api/modules/session.js +16 -16
- package/dist/api/modules/startscreen.d.ts +2 -3
- package/dist/api/modules/startscreen.js +8 -9
- package/dist/api/modules/statistic.d.ts +2 -1
- package/dist/api/modules/statistic.js +4 -7
- package/dist/api/modules/worker.d.ts +2 -1
- package/dist/api/modules/worker.js +3 -3
- package/package.json +3 -2
- package/src/api/index.ts +16 -15
- package/src/api/main.ts +33 -24
- package/src/api/modules/action.ts +2 -4
- package/src/api/modules/base.ts +77 -79
- package/src/api/modules/builder.ts +2 -14
- package/src/api/modules/checker.ts +36 -37
- package/src/api/modules/client.ts +144 -136
- package/src/api/modules/component.ts +1826 -0
- package/src/api/modules/config.ts +86 -7
- package/src/api/modules/console.ts +25 -25
- package/src/api/modules/cooldown.ts +8 -13
- package/src/api/modules/database.ts +24 -32
- package/src/api/modules/event.ts +6 -10
- package/src/api/modules/fuse.ts +1 -1
- package/src/api/modules/helpmenu.ts +31 -27
- package/src/api/modules/language.ts +11 -16
- package/src/api/modules/permission.ts +17 -20
- package/src/api/modules/plugin.ts +2 -2
- package/src/api/modules/post.ts +31 -10
- package/src/api/modules/progressbar.ts +36 -37
- package/src/api/modules/responder.ts +234 -185
- package/src/api/modules/session.ts +15 -15
- package/src/api/modules/startscreen.ts +9 -10
- package/src/api/modules/statistic.ts +4 -7
- package/src/api/modules/worker.ts +3 -3
- package/src/api/modules/component.txt +0 -350
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//CONFIG CHECKER MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
4
|
import { ODId, ODManager, ODManagerData } from "./base.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ODMemoryConfig } from "./config.js";
|
|
6
6
|
import ansis from "ansis";
|
|
7
7
|
/**## ODCheckerManager `class`
|
|
8
8
|
* This is an Open Discord checker manager.
|
|
@@ -66,7 +66,7 @@ export class ODCheckerManager extends ODManager {
|
|
|
66
66
|
}
|
|
67
67
|
/**Create temporary and unlisted `ODConfig`, `ODChecker` & `ODCheckerStorage` classes. This will help you use a `ODCheckerStructure` validator without officially registering it in `opendiscord.checkers`. */
|
|
68
68
|
createTemporaryCheckerEnvironment() {
|
|
69
|
-
return new ODChecker("opendiscord:temporary-environment", new ODCheckerStorage(), 0, new
|
|
69
|
+
return new ODChecker("opendiscord:temporary-environment", new ODCheckerStorage(), 0, new ODMemoryConfig("opendiscord:temporary-environment", {}), new ODCheckerStructure("opendiscord:temporary-environment", {}));
|
|
70
70
|
}
|
|
71
71
|
get(id) {
|
|
72
72
|
return super.get(id);
|
|
@@ -139,10 +139,6 @@ export class ODCheckerStorage {
|
|
|
139
139
|
* Use this class to change the config checker looks!
|
|
140
140
|
*/
|
|
141
141
|
export class ODCheckerRenderer {
|
|
142
|
-
/**Get all config checker render components. These can be combined and rendered to the console. */
|
|
143
|
-
getComponents(compact, renderEmpty, translation, data) {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
142
|
/**Render all config checker render components to the console. */
|
|
147
143
|
render(components) {
|
|
148
144
|
if (components.length < 1)
|
|
@@ -225,17 +221,17 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
|
|
|
225
221
|
const finalFooter = [footerErrorText, footerWarningText, footerSupportText, ...this.extraFooterText];
|
|
226
222
|
const finalTop = [...this.extraTopText];
|
|
227
223
|
const finalBottom = [bottomCompactInfo, ...this.extraBottomText];
|
|
228
|
-
const borderLength = this
|
|
224
|
+
const borderLength = this.getLongestLength([...finalHeader, ...finalFooter]);
|
|
229
225
|
const finalComponents = [];
|
|
230
226
|
//header
|
|
231
227
|
if (!this.disableHeader) {
|
|
232
228
|
finalHeader.forEach((text) => {
|
|
233
229
|
if (text.length < 1)
|
|
234
230
|
return;
|
|
235
|
-
finalComponents.push(this
|
|
231
|
+
finalComponents.push(this.createBlockFromText(text, borderLength));
|
|
236
232
|
});
|
|
237
233
|
}
|
|
238
|
-
finalComponents.push(this
|
|
234
|
+
finalComponents.push(this.getHorizontalDivider(borderLength + 4));
|
|
239
235
|
//top
|
|
240
236
|
finalTop.forEach((text) => {
|
|
241
237
|
if (text.length < 1)
|
|
@@ -293,24 +289,24 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
|
|
|
293
289
|
finalComponents.push(this.verticalFiller + " " + text);
|
|
294
290
|
});
|
|
295
291
|
//footer
|
|
296
|
-
finalComponents.push(this
|
|
292
|
+
finalComponents.push(this.getHorizontalDivider(borderLength + 4));
|
|
297
293
|
if (!this.disableFooter) {
|
|
298
294
|
finalFooter.forEach((text) => {
|
|
299
295
|
if (text.length < 1)
|
|
300
296
|
return;
|
|
301
|
-
finalComponents.push(this
|
|
297
|
+
finalComponents.push(this.createBlockFromText(text, borderLength));
|
|
302
298
|
});
|
|
303
|
-
finalComponents.push(this
|
|
299
|
+
finalComponents.push(this.getHorizontalDivider(borderLength + 4));
|
|
304
300
|
}
|
|
305
301
|
//return all components
|
|
306
302
|
return finalComponents;
|
|
307
303
|
}
|
|
308
304
|
/**Get the length of the longest string in the array. */
|
|
309
|
-
|
|
305
|
+
getLongestLength(texts) {
|
|
310
306
|
return Math.max(...texts.map((t) => ansis.strip(t).length));
|
|
311
307
|
}
|
|
312
308
|
/**Get a horizontal divider used between different parts of the config checker result. */
|
|
313
|
-
|
|
309
|
+
getHorizontalDivider(width) {
|
|
314
310
|
if (width > 2)
|
|
315
311
|
width = width - 2;
|
|
316
312
|
else
|
|
@@ -319,7 +315,7 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
|
|
|
319
315
|
return divider;
|
|
320
316
|
}
|
|
321
317
|
/**Create a block of text with a vertical divider on the left & right side. */
|
|
322
|
-
|
|
318
|
+
createBlockFromText(text, width) {
|
|
323
319
|
if (width < 3)
|
|
324
320
|
return this.verticalFiller + this.verticalFiller;
|
|
325
321
|
let newWidth = width - ansis.strip(text).length + 1;
|
|
@@ -337,28 +333,28 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
|
|
|
337
333
|
*/
|
|
338
334
|
export class ODCheckerTranslationRegister {
|
|
339
335
|
/**This is the array that stores all the data. ❌ **(don't edit unless really needed!)***/
|
|
340
|
-
|
|
336
|
+
translations = [];
|
|
341
337
|
get(type, id) {
|
|
342
|
-
const result = this
|
|
338
|
+
const result = this.translations.find(d => (d.id == id) && (d.type == type));
|
|
343
339
|
return (result) ? result.translation : null;
|
|
344
340
|
}
|
|
345
341
|
set(type, id, translation) {
|
|
346
|
-
const index = this
|
|
342
|
+
const index = this.translations.findIndex(d => (d.id == id) && (d.type == type));
|
|
347
343
|
if (index > -1) {
|
|
348
344
|
//overwrite
|
|
349
|
-
this
|
|
345
|
+
this.translations[index] = { type, id, translation };
|
|
350
346
|
return true;
|
|
351
347
|
}
|
|
352
348
|
else {
|
|
353
|
-
this
|
|
349
|
+
this.translations.push({ type, id, translation });
|
|
354
350
|
return false;
|
|
355
351
|
}
|
|
356
352
|
}
|
|
357
353
|
delete(type, id) {
|
|
358
|
-
const index = this
|
|
354
|
+
const index = this.translations.findIndex(d => (d.id == id) && (d.type == type));
|
|
359
355
|
if (index > -1) {
|
|
360
356
|
//delete
|
|
361
|
-
this
|
|
357
|
+
this.translations.splice(index, 1);
|
|
362
358
|
return true;
|
|
363
359
|
}
|
|
364
360
|
else
|
|
@@ -366,7 +362,7 @@ export class ODCheckerTranslationRegister {
|
|
|
366
362
|
}
|
|
367
363
|
/**Get all translations */
|
|
368
364
|
getAll() {
|
|
369
|
-
return this
|
|
365
|
+
return this.translations;
|
|
370
366
|
}
|
|
371
367
|
/**Insert the translation params into the text. */
|
|
372
368
|
insertTranslationParams(text, translationParams) {
|
|
@@ -477,7 +473,7 @@ export class ODChecker extends ODManagerData {
|
|
|
477
473
|
this.options = options ?? {};
|
|
478
474
|
}
|
|
479
475
|
/**Get a human-readable number string. */
|
|
480
|
-
|
|
476
|
+
ordinalNumber(num) {
|
|
481
477
|
const i = Math.abs(Math.round(num));
|
|
482
478
|
const cent = i % 100;
|
|
483
479
|
if (cent >= 10 && cent <= 20)
|
|
@@ -506,7 +502,7 @@ export class ODChecker extends ODManagerData {
|
|
|
506
502
|
const final = [];
|
|
507
503
|
trace.forEach((t) => {
|
|
508
504
|
if (typeof t == "number") {
|
|
509
|
-
final.push(`:(${this
|
|
505
|
+
final.push(`:(${this.ordinalNumber(t + 1)})`);
|
|
510
506
|
}
|
|
511
507
|
else {
|
|
512
508
|
final.push(`."${t}"`);
|
|
@@ -849,11 +845,11 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
|
|
|
849
845
|
checker.createMessage("opendiscord:array-length-invalid", "error", `This array needs to have a length of ${this.options.length}!`, lt, null, [this.options.length.toString()], this.id, (this.options.docs ?? null));
|
|
850
846
|
return false;
|
|
851
847
|
}
|
|
852
|
-
else if (typeof this.options.allowedTypes != "undefined" && !this
|
|
848
|
+
else if (typeof this.options.allowedTypes != "undefined" && !this.arrayAllowedTypesCheck(value, this.options.allowedTypes)) {
|
|
853
849
|
checker.createMessage("opendiscord:array-invalid-types", "error", `This array can only contain the following types: ${this.options.allowedTypes.join(", ")}!`, lt, null, [this.options.allowedTypes.join(", ").toString()], this.id, (this.options.docs ?? null));
|
|
854
850
|
return false;
|
|
855
851
|
}
|
|
856
|
-
else if (typeof this.options.allowDoubles != "undefined" && !this.options.allowDoubles && this
|
|
852
|
+
else if (typeof this.options.allowDoubles != "undefined" && !this.options.allowDoubles && this.arrayHasDoubles(value)) {
|
|
857
853
|
checker.createMessage("opendiscord:array-double", "error", "This array doesn't allow the same value twice!", lt, null, [], this.id, (this.options.docs ?? null));
|
|
858
854
|
return false;
|
|
859
855
|
}
|
|
@@ -879,7 +875,7 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
|
|
|
879
875
|
}
|
|
880
876
|
}
|
|
881
877
|
/**Check this array for the allowed types */
|
|
882
|
-
|
|
878
|
+
arrayAllowedTypesCheck(array, allowedTypes) {
|
|
883
879
|
//return TRUE if ALL values are valid
|
|
884
880
|
return !array.some((value) => {
|
|
885
881
|
if (allowedTypes.includes("string") && typeof value == "string") {
|
|
@@ -909,7 +905,7 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
|
|
|
909
905
|
});
|
|
910
906
|
}
|
|
911
907
|
/**Check this array for doubles */
|
|
912
|
-
|
|
908
|
+
arrayHasDoubles(array) {
|
|
913
909
|
const alreadyFound = [];
|
|
914
910
|
let hasDoubles = false;
|
|
915
911
|
array.forEach((value) => {
|
|
@@ -1274,7 +1270,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1274
1270
|
else if (emptyAllowed && value.length == 0) {
|
|
1275
1271
|
return true;
|
|
1276
1272
|
}
|
|
1277
|
-
else if (!this
|
|
1273
|
+
else if (!this.urlIsValid(value)) {
|
|
1278
1274
|
checker.createMessage("opendiscord:url-invalid", "error", "This url is invalid!", lt, null, [], this.id, (this.options.docs ?? null));
|
|
1279
1275
|
return false;
|
|
1280
1276
|
}
|
|
@@ -1286,15 +1282,15 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1286
1282
|
checker.createMessage("opendiscord:url-invalid-protocol", "error", "This url can only use the http:// & https:// protocols!", lt, null, [], this.id, (this.options.docs ?? null));
|
|
1287
1283
|
return false;
|
|
1288
1284
|
}
|
|
1289
|
-
else if (typeof this.urlSettings.allowedHostnames != "undefined" && !this
|
|
1285
|
+
else if (typeof this.urlSettings.allowedHostnames != "undefined" && !this.urlHasValidHostname(value, this.urlSettings.allowedHostnames)) {
|
|
1290
1286
|
checker.createMessage("opendiscord:url-invalid-hostname", "error", "This url has a disallowed hostname!", lt, null, [], this.id, (this.options.docs ?? null));
|
|
1291
1287
|
return false;
|
|
1292
1288
|
}
|
|
1293
|
-
else if (typeof this.urlSettings.allowedExtensions != "undefined" && !this
|
|
1289
|
+
else if (typeof this.urlSettings.allowedExtensions != "undefined" && !this.urlHasValidExtension(value, this.urlSettings.allowedExtensions)) {
|
|
1294
1290
|
checker.createMessage("opendiscord:url-invalid-extension", "error", `This url has an invalid extension! Choose between: ${this.urlSettings.allowedExtensions.join(", ")}!"`, lt, null, [this.urlSettings.allowedExtensions.join(", ")], this.id, (this.options.docs ?? null));
|
|
1295
1291
|
return false;
|
|
1296
1292
|
}
|
|
1297
|
-
else if (typeof this.urlSettings.allowedPaths != "undefined" && !this
|
|
1293
|
+
else if (typeof this.urlSettings.allowedPaths != "undefined" && !this.urlHasValidPath(value, this.urlSettings.allowedPaths)) {
|
|
1298
1294
|
checker.createMessage("opendiscord:url-invalid-path", "error", "This url has an invalid path!", lt, null, [], this.id, (this.options.docs ?? null));
|
|
1299
1295
|
return false;
|
|
1300
1296
|
}
|
|
@@ -1310,7 +1306,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1310
1306
|
this.emptyAllowed = emptyAllowed;
|
|
1311
1307
|
}
|
|
1312
1308
|
/**Check for the hostname */
|
|
1313
|
-
|
|
1309
|
+
urlHasValidHostname(url, hostnames) {
|
|
1314
1310
|
try {
|
|
1315
1311
|
const hostname = new URL(url).hostname;
|
|
1316
1312
|
return hostnames.some((rule) => {
|
|
@@ -1327,7 +1323,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1327
1323
|
}
|
|
1328
1324
|
}
|
|
1329
1325
|
/**Check for the extension */
|
|
1330
|
-
|
|
1326
|
+
urlHasValidExtension(url, extensions) {
|
|
1331
1327
|
try {
|
|
1332
1328
|
const path = new URL(url).pathname;
|
|
1333
1329
|
return extensions.some((rule) => {
|
|
@@ -1339,7 +1335,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1339
1335
|
}
|
|
1340
1336
|
}
|
|
1341
1337
|
/**Check for the path */
|
|
1342
|
-
|
|
1338
|
+
urlHasValidPath(url, paths) {
|
|
1343
1339
|
try {
|
|
1344
1340
|
const path = new URL(url).pathname;
|
|
1345
1341
|
return paths.some((rule) => {
|
|
@@ -1356,7 +1352,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
|
|
|
1356
1352
|
}
|
|
1357
1353
|
}
|
|
1358
1354
|
/**Do general syntax check on url */
|
|
1359
|
-
|
|
1355
|
+
urlIsValid(url) {
|
|
1360
1356
|
try {
|
|
1361
1357
|
new URL(url);
|
|
1362
1358
|
return true;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
|
|
2
2
|
import * as discord from "discord.js";
|
|
3
3
|
import { ODDebugger } from "./console.js";
|
|
4
|
-
import { ODMessageBuildResult
|
|
4
|
+
import { ODMessageBuildResult } from "./builder.js";
|
|
5
5
|
import { ODManualProgressBar } from "./progressbar.js";
|
|
6
|
+
import { ODResponderSendResult } from "./responder.js";
|
|
7
|
+
import { ODMessageComponentBuildResult } from "./component.js";
|
|
6
8
|
/**## ODClientIntents `type`
|
|
7
9
|
* A list of intents required when inviting the bot.
|
|
8
10
|
*/
|
|
@@ -27,7 +29,8 @@ export type ODClientPermissions = ("CreateInstantInvite" | "KickMembers" | "BanM
|
|
|
27
29
|
* If you want, you can also listen for custom events on the `ODClientManager.client` variable (`discord.Client`)
|
|
28
30
|
*/
|
|
29
31
|
export declare class ODClientManager<SlashIdList extends ODSlashCommandManagerIdConstraint = ODSlashCommandManagerIdConstraint, TextIdList extends ODTextCommandManagerIdConstraint = ODTextCommandManagerIdConstraint, ContextMenuIdList extends ODContextMenuManagerIdConstraint = ODContextMenuManagerIdConstraint> {
|
|
30
|
-
|
|
32
|
+
/**Alias to Open Discord debugger. */
|
|
33
|
+
protected debug: ODDebugger;
|
|
31
34
|
/**List of required bot intents. Add intents to this list using the `onClientLoad` event. */
|
|
32
35
|
intents: ODClientIntents[];
|
|
33
36
|
/**List of required bot privileged intents. Add intents to this list using the `onClientLoad` event. */
|
|
@@ -39,6 +42,8 @@ export declare class ODClientManager<SlashIdList extends ODSlashCommandManagerId
|
|
|
39
42
|
/**The discord bot token, empty by default. */
|
|
40
43
|
set token(value: string);
|
|
41
44
|
get token(): string;
|
|
45
|
+
/**The discord bot token. **DON'T USE THIS!!!** (use `ODClientManager.token` instead) */
|
|
46
|
+
private rawBotToken;
|
|
42
47
|
/**The discord.js `discord.Client`. Only use it when initiated! */
|
|
43
48
|
client: discord.Client<true>;
|
|
44
49
|
/**The discord.js REST client. Used for stuff that discord.js can't handle :) */
|
|
@@ -94,7 +99,7 @@ export declare class ODClientManager<SlashIdList extends ODSlashCommandManagerId
|
|
|
94
99
|
fetchGuildChannelMessage(guildId: string | discord.Guild, channelId: string | discord.TextChannel, id: string): Promise<discord.Message<true> | null>;
|
|
95
100
|
fetchGuildChannelMessage(channelId: discord.TextChannel, id: string): Promise<discord.Message<true> | null>;
|
|
96
101
|
/**A simplified shortcut to send a DM to a user :) */
|
|
97
|
-
sendUserDm(user: string | discord.User,
|
|
102
|
+
sendUserDm(user: string | discord.User, build: ODMessageBuildResult | ODMessageComponentBuildResult): Promise<ODResponderSendResult<false>>;
|
|
98
103
|
}
|
|
99
104
|
/**## ODClientActivityType `type`
|
|
100
105
|
* Possible activity types for the bot.
|
|
@@ -112,7 +117,10 @@ export type ODClientActivityMode = ("online" | "invisible" | "idle" | "dnd");
|
|
|
112
117
|
* It also has a built-in refresh function, so the status will refresh every 10 minutes to keep it visible.
|
|
113
118
|
*/
|
|
114
119
|
export declare class ODClientActivityManager {
|
|
115
|
-
|
|
120
|
+
/**Alias to Open Discord debugger. */
|
|
121
|
+
protected debug: ODDebugger;
|
|
122
|
+
/**Copy of discord.js client */
|
|
123
|
+
protected client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>;
|
|
116
124
|
/**The current status type */
|
|
117
125
|
type: ODClientActivityType;
|
|
118
126
|
/**The current status text */
|
|
@@ -127,11 +135,15 @@ export declare class ODClientActivityManager {
|
|
|
127
135
|
refreshInterval: number;
|
|
128
136
|
/**Is the status already initiated? */
|
|
129
137
|
initiated: boolean;
|
|
130
|
-
constructor(debug: ODDebugger,
|
|
138
|
+
constructor(debug: ODDebugger, client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
|
|
131
139
|
/**Update the status. When already initiated, it can take up to 10min to see the updated status in discord. */
|
|
132
140
|
setStatus(type: ODClientActivityType, text: string, mode: ODClientActivityMode, state: string, forceUpdate?: boolean): void;
|
|
133
141
|
/**When initiating the status, the bot starts updating the status using `discord.js`. Returns `true` when successfull. */
|
|
134
142
|
initStatus(): boolean;
|
|
143
|
+
/**Update the client status */
|
|
144
|
+
private updateClientActivity;
|
|
145
|
+
/**Get the enum that links to the correct type */
|
|
146
|
+
private getStatusTypeEnum;
|
|
135
147
|
/**Get the status type (for displaying the status) */
|
|
136
148
|
getStatusType(): "listening " | "playing " | "watching " | "";
|
|
137
149
|
}
|
|
@@ -238,7 +250,12 @@ export interface ODSlashCommandBuilder extends discord.ChatInputApplicationComma
|
|
|
238
250
|
* A utility class to compare existing slash commands with newly registered ones.
|
|
239
251
|
*/
|
|
240
252
|
export declare class ODSlashCommandComparator {
|
|
241
|
-
|
|
253
|
+
/**Convert a `discord.ApplicationCommandOptionChoiceData<string>` to a universal Open Discord slash command option choice object for comparison. */
|
|
254
|
+
protected convertOptionChoice(choice: discord.ApplicationCommandOptionChoiceData<string>): ODSlashCommandUniversalOptionChoice;
|
|
255
|
+
/**Convert a `discord.ApplicationCommandOptionData` to a universal Open Discord slash command option object for comparison. */
|
|
256
|
+
protected convertBuilderOption(option: discord.ApplicationCommandOptionData): ODSlashCommandUniversalOption;
|
|
257
|
+
/**Convert a `discord.ApplicationCommandOption` to a universal Open Discord slash command option object for comparison. */
|
|
258
|
+
protected convertCommandOption(option: discord.ApplicationCommandOption): ODSlashCommandUniversalOption;
|
|
242
259
|
/**Convert a `ODSlashCommandBuilder` to a universal Open Discord slash command object for comparison. */
|
|
243
260
|
convertBuilder(builder: ODSlashCommandBuilder, guildId: string | null): ODSlashCommandUniversalCommand | null;
|
|
244
261
|
/**Convert a `discord.ApplicationCommand` to a universal Open Discord slash command object for comparison. */
|
|
@@ -296,14 +313,20 @@ export type ODSlashCommandManagerIdConstraint = Record<string, ODSlashCommand>;
|
|
|
296
313
|
* Here, you can add & remove slash commands & the bot will do the (de)registering.
|
|
297
314
|
*/
|
|
298
315
|
export declare class ODSlashCommandManager<IdList extends ODSlashCommandManagerIdConstraint = ODSlashCommandManagerIdConstraint> extends ODManager<ODSlashCommand> {
|
|
299
|
-
|
|
316
|
+
/**Refrerence to discord.js client. */
|
|
317
|
+
protected client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>;
|
|
300
318
|
/**Discord.js application commands manager. */
|
|
301
319
|
commandManager: discord.ApplicationCommandManager | null;
|
|
320
|
+
/**Collection of all interaction listeners. */
|
|
321
|
+
protected interactionListeners: {
|
|
322
|
+
name: string | RegExp;
|
|
323
|
+
callback: ODSlashCommandInteractionCallback;
|
|
324
|
+
}[];
|
|
302
325
|
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
303
326
|
listenerLimit: number;
|
|
304
327
|
/**A utility class used to compare 2 slash commands with each other. */
|
|
305
328
|
comparator: ODSlashCommandComparator;
|
|
306
|
-
constructor(debug: ODDebugger,
|
|
329
|
+
constructor(debug: ODDebugger, client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
|
|
307
330
|
/**Get all registered & unregistered slash commands. */
|
|
308
331
|
getAllRegisteredCommands(guildId?: string): Promise<ODSlashCommandRegisteredResult>;
|
|
309
332
|
/**Create all commands that are not registered yet.*/
|
|
@@ -586,12 +609,26 @@ export type ODTextCommandManagerIdConstraint = Record<string, ODTextCommand>;
|
|
|
586
609
|
* Here, you can add & remove text commands & the bot will do the (de)registering.
|
|
587
610
|
*/
|
|
588
611
|
export declare class ODTextCommandManager<IdList extends ODTextCommandManagerIdConstraint = ODTextCommandManagerIdConstraint> extends ODManager<ODTextCommand> {
|
|
589
|
-
|
|
612
|
+
/**Copy of discord.js client. */
|
|
613
|
+
protected client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>;
|
|
614
|
+
/**Collection of all interaction listeners. */
|
|
615
|
+
protected interactionListeners: {
|
|
616
|
+
prefix: string;
|
|
617
|
+
name: string | RegExp;
|
|
618
|
+
callback: ODTextCommandInteractionCallback;
|
|
619
|
+
}[];
|
|
620
|
+
/**Collection of all error listeners. */
|
|
621
|
+
protected errorListeners: ODTextCommandErrorCallback[];
|
|
590
622
|
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
591
623
|
listenerLimit: number;
|
|
592
|
-
constructor(debug: ODDebugger,
|
|
624
|
+
constructor(debug: ODDebugger, client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
|
|
625
|
+
private checkMessage;
|
|
626
|
+
/**Check if all options of a command are correct. */
|
|
627
|
+
private checkOptions;
|
|
593
628
|
/**Start listening to the discord.js client `messageCreate` event. */
|
|
594
629
|
startListeningToInteractions(): void;
|
|
630
|
+
/**Check if optional values are only present at the end of the command. */
|
|
631
|
+
private checkBuilderOptions;
|
|
595
632
|
/**Callback on interaction from one of the registered text commands */
|
|
596
633
|
onInteraction(commandPrefix: string, commandName: keyof ODNoGeneric<IdList>, callback: ODTextCommandInteractionCallback): void;
|
|
597
634
|
onInteraction(commandPrefix: string, commandName: string | RegExp, callback: ODTextCommandInteractionCallback): void;
|
|
@@ -711,14 +748,20 @@ export type ODContextMenuManagerIdConstraint = Record<string, ODContextMenu>;
|
|
|
711
748
|
* Here, you can add & remove context interactions & the bot will do the (de)registering.
|
|
712
749
|
*/
|
|
713
750
|
export declare class ODContextMenuManager<IdList extends ODContextMenuManagerIdConstraint = ODContextMenuManagerIdConstraint> extends ODManager<ODContextMenu> {
|
|
714
|
-
|
|
751
|
+
/**Refrerence to discord.js client. */
|
|
752
|
+
protected client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>;
|
|
715
753
|
/**Discord.js application commands manager. */
|
|
716
754
|
commandManager: discord.ApplicationCommandManager | null;
|
|
755
|
+
/**Collection of all interaction listeners. */
|
|
756
|
+
protected interactionListeners: {
|
|
757
|
+
name: string | RegExp;
|
|
758
|
+
callback: ODContextMenuInteractionCallback;
|
|
759
|
+
}[];
|
|
717
760
|
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
718
761
|
listenerLimit: number;
|
|
719
762
|
/**A utility class used to compare 2 context menus with each other. */
|
|
720
763
|
comparator: ODContextMenuComparator;
|
|
721
|
-
constructor(debug: ODDebugger,
|
|
764
|
+
constructor(debug: ODDebugger, client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
|
|
722
765
|
/**Get all registered & unregistered message context menu commands. */
|
|
723
766
|
getAllRegisteredMenus(guildId?: string): Promise<ODContextMenuRegisteredResult>;
|
|
724
767
|
/**Create all context menus that are not registered yet.*/
|
|
@@ -778,12 +821,21 @@ export type ODAutocompleteInteractionCallback = (interaction: discord.Autocomple
|
|
|
778
821
|
* It's responsible for managing all the autocomplete interactions from the client.
|
|
779
822
|
*/
|
|
780
823
|
export declare class ODAutocompleteManager {
|
|
781
|
-
|
|
824
|
+
/**Alias to Open Discord debugger. */
|
|
825
|
+
protected debug: ODDebugger;
|
|
826
|
+
/**Refrerence to discord.js client. */
|
|
827
|
+
protected client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>;
|
|
782
828
|
/**Discord.js application commands manager. */
|
|
783
829
|
commandManager: discord.ApplicationCommandManager | null;
|
|
830
|
+
/**Collection of all interaction listeners. */
|
|
831
|
+
protected interactionListeners: {
|
|
832
|
+
cmdName: string | RegExp;
|
|
833
|
+
optName: string | RegExp;
|
|
834
|
+
callback: ODAutocompleteInteractionCallback;
|
|
835
|
+
}[];
|
|
784
836
|
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
785
837
|
listenerLimit: number;
|
|
786
|
-
constructor(debug: ODDebugger,
|
|
838
|
+
constructor(debug: ODDebugger, client: ODClientManager<ODSlashCommandManagerIdConstraint, ODTextCommandManagerIdConstraint, ODContextMenuManagerIdConstraint>);
|
|
787
839
|
/**Start listening to the discord.js client `interactionCreate` event. */
|
|
788
840
|
startListeningToInteractions(): void;
|
|
789
841
|
/**Callback on interaction from one or multiple autocompletes. */
|