@open-discord-bots/framework 0.2.11 → 0.2.13
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 +26 -26
- package/dist/api/index.js +26 -42
- package/dist/api/main.d.ts +24 -24
- package/dist/api/main.js +7 -11
- package/dist/api/modules/action.d.ts +12 -12
- package/dist/api/modules/action.js +11 -17
- package/dist/api/modules/base.d.ts +7 -5
- package/dist/api/modules/base.js +22 -67
- package/dist/api/modules/builder.d.ts +44 -44
- package/dist/api/modules/builder.js +81 -142
- package/dist/api/modules/checker.d.ts +7 -7
- package/dist/api/modules/checker.js +55 -87
- package/dist/api/modules/client.d.ts +4 -4
- package/dist/api/modules/client.js +71 -118
- package/dist/api/modules/code.d.ts +2 -2
- package/dist/api/modules/code.js +3 -8
- package/dist/api/modules/config.d.ts +2 -2
- package/dist/api/modules/config.js +21 -63
- package/dist/api/modules/console.d.ts +16 -16
- package/dist/api/modules/console.js +61 -83
- package/dist/api/modules/cooldown.d.ts +2 -2
- package/dist/api/modules/cooldown.js +13 -23
- package/dist/api/modules/database.d.ts +2 -2
- package/dist/api/modules/database.js +19 -29
- package/dist/api/modules/event.d.ts +2 -2
- package/dist/api/modules/event.js +6 -11
- package/dist/api/modules/flag.d.ts +2 -2
- package/dist/api/modules/flag.js +3 -8
- package/dist/api/modules/fuse.js +2 -7
- package/dist/api/modules/helpmenu.d.ts +2 -2
- package/dist/api/modules/helpmenu.js +8 -16
- package/dist/api/modules/language.d.ts +2 -2
- package/dist/api/modules/language.js +12 -21
- package/dist/api/modules/permission.d.ts +3 -3
- package/dist/api/modules/permission.js +9 -47
- package/dist/api/modules/plugin.d.ts +2 -2
- package/dist/api/modules/plugin.js +9 -18
- package/dist/api/modules/post.d.ts +3 -3
- package/dist/api/modules/post.js +3 -8
- package/dist/api/modules/progressbar.d.ts +2 -2
- package/dist/api/modules/progressbar.js +14 -26
- package/dist/api/modules/responder.d.ts +42 -42
- package/dist/api/modules/responder.js +79 -138
- package/dist/api/modules/session.d.ts +2 -2
- package/dist/api/modules/session.js +4 -42
- package/dist/api/modules/startscreen.d.ts +4 -4
- package/dist/api/modules/startscreen.js +28 -44
- package/dist/api/modules/statistic.d.ts +3 -3
- package/dist/api/modules/statistic.js +11 -22
- package/dist/api/modules/verifybar.d.ts +5 -5
- package/dist/api/modules/verifybar.js +6 -11
- package/dist/api/modules/worker.d.ts +15 -15
- package/dist/api/modules/worker.js +12 -17
- package/dist/cli/editConfig.d.ts +2 -2
- package/dist/cli/editConfig.js +194 -248
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +37 -62
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -13
- package/dist/startup/compilation.d.ts +1 -1
- package/dist/startup/compilation.js +35 -42
- package/dist/startup/dump.d.ts +1 -1
- package/dist/startup/dump.js +4 -41
- package/dist/startup/errorHandling.d.ts +1 -1
- package/dist/startup/errorHandling.js +2 -38
- package/dist/startup/pluginLauncher.d.ts +1 -1
- package/dist/startup/pluginLauncher.js +14 -52
- package/dist/utilities/index.d.ts +3 -3
- package/dist/utilities/index.js +20 -71
- package/package.json +5 -4
- package/src/api/index.ts +26 -26
- package/src/api/main.ts +25 -25
- package/src/api/modules/action.ts +13 -13
- package/src/api/modules/base.ts +14 -10
- package/src/api/modules/builder.ts +56 -56
- package/src/api/modules/checker.ts +7 -7
- package/src/api/modules/client.ts +18 -18
- package/src/api/modules/code.ts +2 -2
- package/src/api/modules/component.txt +350 -0
- package/src/api/modules/config.ts +3 -3
- package/src/api/modules/console.ts +28 -28
- package/src/api/modules/cooldown.ts +2 -2
- package/src/api/modules/database.ts +3 -3
- package/src/api/modules/event.ts +5 -5
- package/src/api/modules/flag.ts +2 -2
- package/src/api/modules/helpmenu.ts +4 -4
- package/src/api/modules/language.ts +3 -3
- package/src/api/modules/permission.ts +3 -3
- package/src/api/modules/plugin.ts +4 -4
- package/src/api/modules/post.ts +3 -3
- package/src/api/modules/progressbar.ts +5 -3
- package/src/api/modules/responder.ts +48 -48
- package/src/api/modules/session.ts +2 -2
- package/src/api/modules/startscreen.ts +4 -4
- package/src/api/modules/statistic.ts +3 -4
- package/src/api/modules/verifybar.ts +5 -5
- package/src/api/modules/worker.ts +25 -25
- package/src/cli/editConfig.ts +23 -37
- package/src/cli/index.ts +3 -3
- package/src/index.ts +5 -5
- package/src/startup/compilation.ts +2 -2
- package/src/startup/dump.ts +2 -2
- package/src/startup/errorHandling.ts +2 -2
- package/src/startup/pluginLauncher.ts +11 -8
- package/src/utilities/index.ts +4 -4
- package/tools/cleanup.js +1 -1
- package/tsconfig.json +2 -1
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ODModal = exports.ODModalInstance = exports.ODModalManager = exports.ODQuickMessage = exports.ODMessage = exports.ODMessageInstance = exports.ODMessageManager = exports.ODQuickEmbed = exports.ODEmbed = exports.ODEmbedInstance = exports.ODEmbedManager = exports.ODQuickFile = exports.ODFile = exports.ODFileInstance = exports.ODFileManager = exports.ODQuickDropdown = exports.ODDropdown = exports.ODDropdownInstance = exports.ODDropdownManager = exports.ODQuickButton = exports.ODButton = exports.ODButtonInstance = exports.ODButtonManager = exports.ODBuilderManager = exports.ODBuilderImplementation = void 0;
|
|
37
1
|
///////////////////////////////////////
|
|
38
2
|
//BUILDER MODULE
|
|
39
3
|
///////////////////////////////////////
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
4
|
+
import { ODId, ODSystemError, ODManagerWithSafety, ODManagerData } from "./base.js";
|
|
5
|
+
import * as discord from "discord.js";
|
|
6
|
+
import { ODWorkerManager, ODWorker } from "./worker.js";
|
|
43
7
|
/**## ODBuilderImplementation `class`
|
|
44
8
|
* This is an Open Discord builder implementation.
|
|
45
9
|
*
|
|
@@ -47,7 +11,7 @@ const worker_1 = require("./worker");
|
|
|
47
11
|
*
|
|
48
12
|
* This class can't be used stand-alone & needs to be extended from!
|
|
49
13
|
*/
|
|
50
|
-
class ODBuilderImplementation extends
|
|
14
|
+
export class ODBuilderImplementation extends ODManagerData {
|
|
51
15
|
/**The manager that has all workers of this implementation */
|
|
52
16
|
workers;
|
|
53
17
|
/**Cache a build or create it every time from scratch when this.build() gets executed. */
|
|
@@ -58,9 +22,9 @@ class ODBuilderImplementation extends base_1.ODManagerData {
|
|
|
58
22
|
cache = null;
|
|
59
23
|
constructor(id, callback, priority, callbackId) {
|
|
60
24
|
super(id);
|
|
61
|
-
this.workers = new
|
|
25
|
+
this.workers = new ODWorkerManager("ascending");
|
|
62
26
|
if (callback)
|
|
63
|
-
this.workers.add(new
|
|
27
|
+
this.workers.add(new ODWorker(callbackId ? callbackId : id, priority ?? 0, callback));
|
|
64
28
|
}
|
|
65
29
|
/**Set if caching is allowed */
|
|
66
30
|
setCacheMode(allowed) {
|
|
@@ -75,11 +39,10 @@ class ODBuilderImplementation extends base_1.ODManagerData {
|
|
|
75
39
|
return this;
|
|
76
40
|
}
|
|
77
41
|
/**Execute all workers & return the result. */
|
|
78
|
-
async build(
|
|
79
|
-
throw new
|
|
42
|
+
async build(origin, params) {
|
|
43
|
+
throw new ODSystemError("Tried to build an unimplemented ODBuilderImplementation");
|
|
80
44
|
}
|
|
81
45
|
}
|
|
82
|
-
exports.ODBuilderImplementation = ODBuilderImplementation;
|
|
83
46
|
/**## ODBuilderManager `class`
|
|
84
47
|
* This is an Open Discord builder manager.
|
|
85
48
|
*
|
|
@@ -91,10 +54,10 @@ exports.ODBuilderImplementation = ODBuilderImplementation;
|
|
|
91
54
|
* - independent workers (with priority)
|
|
92
55
|
* - fail-safe design using try-catch
|
|
93
56
|
* - cache frequently used objects
|
|
94
|
-
* - get to know the
|
|
57
|
+
* - get to know the origin of the build request for a specific message, button, etc
|
|
95
58
|
* - And so much more!
|
|
96
59
|
*/
|
|
97
|
-
class ODBuilderManager {
|
|
60
|
+
export class ODBuilderManager {
|
|
98
61
|
/**The manager for all button builders */
|
|
99
62
|
buttons;
|
|
100
63
|
/**The manager for all dropdown builders */
|
|
@@ -116,7 +79,6 @@ class ODBuilderManager {
|
|
|
116
79
|
this.modals = new ODModalManager(debug);
|
|
117
80
|
}
|
|
118
81
|
}
|
|
119
|
-
exports.ODBuilderManager = ODBuilderManager;
|
|
120
82
|
/**## ODButtonManager `class`
|
|
121
83
|
* This is an Open Discord button manager.
|
|
122
84
|
*
|
|
@@ -124,10 +86,10 @@ exports.ODBuilderManager = ODBuilderManager;
|
|
|
124
86
|
*
|
|
125
87
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
126
88
|
*/
|
|
127
|
-
class ODButtonManager extends
|
|
89
|
+
export class ODButtonManager extends ODManagerWithSafety {
|
|
128
90
|
constructor(debug) {
|
|
129
91
|
super(() => {
|
|
130
|
-
return new ODButton("opendiscord:unknown-button", (instance, params,
|
|
92
|
+
return new ODButton("opendiscord:unknown-button", (instance, params, origin, cancel) => {
|
|
131
93
|
instance.setCustomId("od:unknown-button");
|
|
132
94
|
instance.setMode("button");
|
|
133
95
|
instance.setColor("red");
|
|
@@ -141,7 +103,7 @@ class ODButtonManager extends base_1.ODManagerWithSafety {
|
|
|
141
103
|
/**Get a newline component for buttons & dropdowns! */
|
|
142
104
|
getNewLine(id) {
|
|
143
105
|
return {
|
|
144
|
-
id: new
|
|
106
|
+
id: new ODId(id),
|
|
145
107
|
component: "\n"
|
|
146
108
|
};
|
|
147
109
|
}
|
|
@@ -158,13 +120,12 @@ class ODButtonManager extends base_1.ODManagerWithSafety {
|
|
|
158
120
|
return super.getSafe(id);
|
|
159
121
|
}
|
|
160
122
|
}
|
|
161
|
-
exports.ODButtonManager = ODButtonManager;
|
|
162
123
|
/**## ODButtonInstance `class`
|
|
163
124
|
* This is an Open Discord button instance.
|
|
164
125
|
*
|
|
165
126
|
* It contains all properties & functions to build a button!
|
|
166
127
|
*/
|
|
167
|
-
class ODButtonInstance {
|
|
128
|
+
export class ODButtonInstance {
|
|
168
129
|
/**The current data of this button */
|
|
169
130
|
data = {
|
|
170
131
|
customId: "",
|
|
@@ -211,7 +172,6 @@ class ODButtonInstance {
|
|
|
211
172
|
return this;
|
|
212
173
|
}
|
|
213
174
|
}
|
|
214
|
-
exports.ODButtonInstance = ODButtonInstance;
|
|
215
175
|
/**## ODButton `class`
|
|
216
176
|
* This is an Open Discord button builder.
|
|
217
177
|
*
|
|
@@ -220,16 +180,16 @@ exports.ODButtonInstance = ODButtonInstance;
|
|
|
220
180
|
*
|
|
221
181
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
222
182
|
*/
|
|
223
|
-
class ODButton extends ODBuilderImplementation {
|
|
183
|
+
export class ODButton extends ODBuilderImplementation {
|
|
224
184
|
/**Build this button & compile it for discord.js */
|
|
225
|
-
async build(
|
|
185
|
+
async build(origin, params) {
|
|
226
186
|
if (this.didCache && this.cache && this.allowCache)
|
|
227
187
|
return this.cache;
|
|
228
188
|
try {
|
|
229
189
|
//create instance
|
|
230
190
|
const instance = new ODButtonInstance();
|
|
231
191
|
//wait for workers to finish
|
|
232
|
-
await this.workers.executeWorkers(instance,
|
|
192
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
233
193
|
//create the discord.js button
|
|
234
194
|
const button = new discord.ButtonBuilder();
|
|
235
195
|
if (instance.data.mode == "button")
|
|
@@ -259,13 +219,12 @@ class ODButton extends ODBuilderImplementation {
|
|
|
259
219
|
return { id: this.id, component: button };
|
|
260
220
|
}
|
|
261
221
|
catch (err) {
|
|
262
|
-
process.emit("uncaughtException", new
|
|
222
|
+
process.emit("uncaughtException", new ODSystemError("ODButton:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
263
223
|
process.emit("uncaughtException", err);
|
|
264
224
|
return { id: this.id, component: null };
|
|
265
225
|
}
|
|
266
226
|
}
|
|
267
227
|
}
|
|
268
|
-
exports.ODButton = ODButton;
|
|
269
228
|
/**## ODQuickButton `class`
|
|
270
229
|
* This is an Open Discord quick button builder.
|
|
271
230
|
*
|
|
@@ -274,13 +233,13 @@ exports.ODButton = ODButton;
|
|
|
274
233
|
*
|
|
275
234
|
* Because of the quick functionality, these buttons are less customisable by other plugins.
|
|
276
235
|
*/
|
|
277
|
-
class ODQuickButton {
|
|
236
|
+
export class ODQuickButton {
|
|
278
237
|
/**The id of this button. */
|
|
279
238
|
id;
|
|
280
239
|
/**The current data of this button */
|
|
281
240
|
data;
|
|
282
241
|
constructor(id, data) {
|
|
283
|
-
this.id = new
|
|
242
|
+
this.id = new ODId(id);
|
|
284
243
|
this.data = data;
|
|
285
244
|
}
|
|
286
245
|
/**Build this button & compile it for discord.js */
|
|
@@ -315,13 +274,12 @@ class ODQuickButton {
|
|
|
315
274
|
return { id: this.id, component: button };
|
|
316
275
|
}
|
|
317
276
|
catch (err) {
|
|
318
|
-
process.emit("uncaughtException", new
|
|
277
|
+
process.emit("uncaughtException", new ODSystemError("ODQuickButton:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
319
278
|
process.emit("uncaughtException", err);
|
|
320
279
|
return { id: this.id, component: null };
|
|
321
280
|
}
|
|
322
281
|
}
|
|
323
282
|
}
|
|
324
|
-
exports.ODQuickButton = ODQuickButton;
|
|
325
283
|
/**## ODDropdownManager `class`
|
|
326
284
|
* This is an Open Discord dropdown manager.
|
|
327
285
|
*
|
|
@@ -329,10 +287,10 @@ exports.ODQuickButton = ODQuickButton;
|
|
|
329
287
|
*
|
|
330
288
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
331
289
|
*/
|
|
332
|
-
class ODDropdownManager extends
|
|
290
|
+
export class ODDropdownManager extends ODManagerWithSafety {
|
|
333
291
|
constructor(debug) {
|
|
334
292
|
super(() => {
|
|
335
|
-
return new ODDropdown("opendiscord:unknown-dropdown", (instance, params,
|
|
293
|
+
return new ODDropdown("opendiscord:unknown-dropdown", (instance, params, origin, cancel) => {
|
|
336
294
|
instance.setCustomId("od:unknown-dropdown");
|
|
337
295
|
instance.setType("string");
|
|
338
296
|
instance.setPlaceholder("❌ <ODError:Unknown Dropdown>");
|
|
@@ -347,7 +305,7 @@ class ODDropdownManager extends base_1.ODManagerWithSafety {
|
|
|
347
305
|
/**Get a newline component for buttons & dropdowns! */
|
|
348
306
|
getNewLine(id) {
|
|
349
307
|
return {
|
|
350
|
-
id: new
|
|
308
|
+
id: new ODId(id),
|
|
351
309
|
component: "\n"
|
|
352
310
|
};
|
|
353
311
|
}
|
|
@@ -364,13 +322,12 @@ class ODDropdownManager extends base_1.ODManagerWithSafety {
|
|
|
364
322
|
return super.getSafe(id);
|
|
365
323
|
}
|
|
366
324
|
}
|
|
367
|
-
exports.ODDropdownManager = ODDropdownManager;
|
|
368
325
|
/**## ODDropdownInstance `class`
|
|
369
326
|
* This is an Open Discord dropdown instance.
|
|
370
327
|
*
|
|
371
328
|
* It contains all properties & functions to build a dropdown!
|
|
372
329
|
*/
|
|
373
|
-
class ODDropdownInstance {
|
|
330
|
+
export class ODDropdownInstance {
|
|
374
331
|
/**The current data of this dropdown */
|
|
375
332
|
data = {
|
|
376
333
|
customId: "",
|
|
@@ -447,7 +404,6 @@ class ODDropdownInstance {
|
|
|
447
404
|
return this;
|
|
448
405
|
}
|
|
449
406
|
}
|
|
450
|
-
exports.ODDropdownInstance = ODDropdownInstance;
|
|
451
407
|
/**## ODDropdown `class`
|
|
452
408
|
* This is an Open Discord dropdown builder.
|
|
453
409
|
*
|
|
@@ -456,16 +412,16 @@ exports.ODDropdownInstance = ODDropdownInstance;
|
|
|
456
412
|
*
|
|
457
413
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
458
414
|
*/
|
|
459
|
-
class ODDropdown extends ODBuilderImplementation {
|
|
415
|
+
export class ODDropdown extends ODBuilderImplementation {
|
|
460
416
|
/**Build this dropdown & compile it for discord.js */
|
|
461
|
-
async build(
|
|
417
|
+
async build(origin, params) {
|
|
462
418
|
if (this.didCache && this.cache && this.allowCache)
|
|
463
419
|
return this.cache;
|
|
464
420
|
try {
|
|
465
421
|
//create instance
|
|
466
422
|
const instance = new ODDropdownInstance();
|
|
467
423
|
//wait for workers to finish
|
|
468
|
-
await this.workers.executeWorkers(instance,
|
|
424
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
469
425
|
//create the discord.js dropdown
|
|
470
426
|
if (instance.data.type == "string") {
|
|
471
427
|
const dropdown = new discord.StringSelectMenuBuilder();
|
|
@@ -565,13 +521,12 @@ class ODDropdown extends ODBuilderImplementation {
|
|
|
565
521
|
}
|
|
566
522
|
}
|
|
567
523
|
catch (err) {
|
|
568
|
-
process.emit("uncaughtException", new
|
|
524
|
+
process.emit("uncaughtException", new ODSystemError("ODDropdown:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
569
525
|
process.emit("uncaughtException", err);
|
|
570
526
|
return { id: this.id, component: null };
|
|
571
527
|
}
|
|
572
528
|
}
|
|
573
529
|
}
|
|
574
|
-
exports.ODDropdown = ODDropdown;
|
|
575
530
|
/**## ODQuickDropdown `class`
|
|
576
531
|
* This is an Open Discord quick dropdown builder.
|
|
577
532
|
*
|
|
@@ -580,13 +535,13 @@ exports.ODDropdown = ODDropdown;
|
|
|
580
535
|
*
|
|
581
536
|
* Because of the quick functionality, these dropdowns are less customisable by other plugins.
|
|
582
537
|
*/
|
|
583
|
-
class ODQuickDropdown {
|
|
538
|
+
export class ODQuickDropdown {
|
|
584
539
|
/**The id of this dropdown. */
|
|
585
540
|
id;
|
|
586
541
|
/**The current data of this dropdown */
|
|
587
542
|
data;
|
|
588
543
|
constructor(id, data) {
|
|
589
|
-
this.id = new
|
|
544
|
+
this.id = new ODId(id);
|
|
590
545
|
this.data = data;
|
|
591
546
|
}
|
|
592
547
|
/**Build this dropdown & compile it for discord.js */
|
|
@@ -595,7 +550,7 @@ class ODQuickDropdown {
|
|
|
595
550
|
//create the discord.js dropdown
|
|
596
551
|
if (this.data.type == "string") {
|
|
597
552
|
if (!this.data.options)
|
|
598
|
-
throw new
|
|
553
|
+
throw new ODSystemError("ODQuickDropdown:build(): " + this.id.value + " => Dropdown requires at least 1 option to be present.");
|
|
599
554
|
const dropdown = new discord.StringSelectMenuBuilder();
|
|
600
555
|
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown");
|
|
601
556
|
dropdown.setOptions(...this.data.options);
|
|
@@ -611,7 +566,7 @@ class ODQuickDropdown {
|
|
|
611
566
|
}
|
|
612
567
|
else if (this.data.type == "user") {
|
|
613
568
|
if (!this.data.users)
|
|
614
|
-
throw new
|
|
569
|
+
throw new ODSystemError("ODQuickDropdown:build(): " + this.id.value + " => Dropdown requires at least 1 user option to be present.");
|
|
615
570
|
const dropdown = new discord.UserSelectMenuBuilder();
|
|
616
571
|
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown");
|
|
617
572
|
if (this.data.users.length > 0)
|
|
@@ -628,7 +583,7 @@ class ODQuickDropdown {
|
|
|
628
583
|
}
|
|
629
584
|
else if (this.data.type == "role") {
|
|
630
585
|
if (!this.data.roles)
|
|
631
|
-
throw new
|
|
586
|
+
throw new ODSystemError("ODQuickDropdown:build(): " + this.id.value + " => Dropdown requires at least 1 role option to be present.");
|
|
632
587
|
const dropdown = new discord.RoleSelectMenuBuilder();
|
|
633
588
|
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown");
|
|
634
589
|
if (this.data.roles.length > 0)
|
|
@@ -645,7 +600,7 @@ class ODQuickDropdown {
|
|
|
645
600
|
}
|
|
646
601
|
else if (this.data.type == "channel") {
|
|
647
602
|
if (!this.data.channels)
|
|
648
|
-
throw new
|
|
603
|
+
throw new ODSystemError("ODQuickDropdown:build(): " + this.id.value + " => Dropdown requires at least 1 channel option to be present.");
|
|
649
604
|
const dropdown = new discord.ChannelSelectMenuBuilder();
|
|
650
605
|
dropdown.setCustomId(this.data.customId ?? "od:unknown-dropdown");
|
|
651
606
|
if (this.data.channels.length > 0)
|
|
@@ -662,7 +617,7 @@ class ODQuickDropdown {
|
|
|
662
617
|
}
|
|
663
618
|
else if (this.data.type == "mentionable") {
|
|
664
619
|
if (!this.data.mentionables)
|
|
665
|
-
throw new
|
|
620
|
+
throw new ODSystemError("ODQuickDropdown:build(): " + this.id.value + " => Dropdown requires at least 1 mentionable option to be present.");
|
|
666
621
|
const dropdown = new discord.MentionableSelectMenuBuilder();
|
|
667
622
|
const values = [];
|
|
668
623
|
this.data.mentionables.forEach((m) => {
|
|
@@ -691,13 +646,12 @@ class ODQuickDropdown {
|
|
|
691
646
|
}
|
|
692
647
|
}
|
|
693
648
|
catch (err) {
|
|
694
|
-
process.emit("uncaughtException", new
|
|
649
|
+
process.emit("uncaughtException", new ODSystemError("ODQuickDropdown:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
695
650
|
process.emit("uncaughtException", err);
|
|
696
651
|
return { id: this.id, component: null };
|
|
697
652
|
}
|
|
698
653
|
}
|
|
699
654
|
}
|
|
700
|
-
exports.ODQuickDropdown = ODQuickDropdown;
|
|
701
655
|
/**## ODFileManager `class`
|
|
702
656
|
* This is an Open Discord file manager.
|
|
703
657
|
*
|
|
@@ -705,10 +659,10 @@ exports.ODQuickDropdown = ODQuickDropdown;
|
|
|
705
659
|
*
|
|
706
660
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
707
661
|
*/
|
|
708
|
-
class ODFileManager extends
|
|
662
|
+
export class ODFileManager extends ODManagerWithSafety {
|
|
709
663
|
constructor(debug) {
|
|
710
664
|
super(() => {
|
|
711
|
-
return new ODFile("opendiscord:unknown-file", (instance, params,
|
|
665
|
+
return new ODFile("opendiscord:unknown-file", (instance, params, origin, cancel) => {
|
|
712
666
|
instance.setName("opendiscord_unknown-file.txt");
|
|
713
667
|
instance.setDescription("❌ <ODError:Unknown File>");
|
|
714
668
|
instance.setContents("Couldn't find file in registery `opendiscord.builders.files`");
|
|
@@ -729,13 +683,12 @@ class ODFileManager extends base_1.ODManagerWithSafety {
|
|
|
729
683
|
return super.getSafe(id);
|
|
730
684
|
}
|
|
731
685
|
}
|
|
732
|
-
exports.ODFileManager = ODFileManager;
|
|
733
686
|
/**## ODFileInstance `class`
|
|
734
687
|
* This is an Open Discord file instance.
|
|
735
688
|
*
|
|
736
689
|
* It contains all properties & functions to build a file!
|
|
737
690
|
*/
|
|
738
|
-
class ODFileInstance {
|
|
691
|
+
export class ODFileInstance {
|
|
739
692
|
/**The current data of this file */
|
|
740
693
|
data = {
|
|
741
694
|
file: "",
|
|
@@ -769,7 +722,6 @@ class ODFileInstance {
|
|
|
769
722
|
return this;
|
|
770
723
|
}
|
|
771
724
|
}
|
|
772
|
-
exports.ODFileInstance = ODFileInstance;
|
|
773
725
|
/**## ODFile `class`
|
|
774
726
|
* This is an Open Discord file builder.
|
|
775
727
|
*
|
|
@@ -778,16 +730,16 @@ exports.ODFileInstance = ODFileInstance;
|
|
|
778
730
|
*
|
|
779
731
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
780
732
|
*/
|
|
781
|
-
class ODFile extends ODBuilderImplementation {
|
|
733
|
+
export class ODFile extends ODBuilderImplementation {
|
|
782
734
|
/**Build this attachment & compile it for discord.js */
|
|
783
|
-
async build(
|
|
735
|
+
async build(origin, params) {
|
|
784
736
|
if (this.didCache && this.cache && this.allowCache)
|
|
785
737
|
return this.cache;
|
|
786
738
|
try {
|
|
787
739
|
//create instance
|
|
788
740
|
const instance = new ODFileInstance();
|
|
789
741
|
//wait for workers to finish
|
|
790
|
-
await this.workers.executeWorkers(instance,
|
|
742
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
791
743
|
//create the discord.js attachment
|
|
792
744
|
const file = new discord.AttachmentBuilder(instance.data.file);
|
|
793
745
|
file.setName(instance.data.name ? instance.data.name : "file.txt");
|
|
@@ -800,13 +752,12 @@ class ODFile extends ODBuilderImplementation {
|
|
|
800
752
|
return { id: this.id, file };
|
|
801
753
|
}
|
|
802
754
|
catch (err) {
|
|
803
|
-
process.emit("uncaughtException", new
|
|
755
|
+
process.emit("uncaughtException", new ODSystemError("ODFile:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
804
756
|
process.emit("uncaughtException", err);
|
|
805
757
|
return { id: this.id, file: null };
|
|
806
758
|
}
|
|
807
759
|
}
|
|
808
760
|
}
|
|
809
|
-
exports.ODFile = ODFile;
|
|
810
761
|
/**## ODQuickFile `class`
|
|
811
762
|
* This is an Open Discord quick file builder.
|
|
812
763
|
*
|
|
@@ -815,13 +766,13 @@ exports.ODFile = ODFile;
|
|
|
815
766
|
*
|
|
816
767
|
* Because of the quick functionality, these files are less customisable by other plugins.
|
|
817
768
|
*/
|
|
818
|
-
class ODQuickFile {
|
|
769
|
+
export class ODQuickFile {
|
|
819
770
|
/**The id of this file. */
|
|
820
771
|
id;
|
|
821
772
|
/**The current data of this file */
|
|
822
773
|
data;
|
|
823
774
|
constructor(id, data) {
|
|
824
|
-
this.id = new
|
|
775
|
+
this.id = new ODId(id);
|
|
825
776
|
this.data = data;
|
|
826
777
|
}
|
|
827
778
|
/**Build this attachment & compile it for discord.js */
|
|
@@ -837,13 +788,12 @@ class ODQuickFile {
|
|
|
837
788
|
return { id: this.id, file };
|
|
838
789
|
}
|
|
839
790
|
catch (err) {
|
|
840
|
-
process.emit("uncaughtException", new
|
|
791
|
+
process.emit("uncaughtException", new ODSystemError("ODQuickFile:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
841
792
|
process.emit("uncaughtException", err);
|
|
842
793
|
return { id: this.id, file: null };
|
|
843
794
|
}
|
|
844
795
|
}
|
|
845
796
|
}
|
|
846
|
-
exports.ODQuickFile = ODQuickFile;
|
|
847
797
|
/**## ODEmbedManager `class`
|
|
848
798
|
* This is an Open Discord embed manager.
|
|
849
799
|
*
|
|
@@ -851,10 +801,10 @@ exports.ODQuickFile = ODQuickFile;
|
|
|
851
801
|
*
|
|
852
802
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
853
803
|
*/
|
|
854
|
-
class ODEmbedManager extends
|
|
804
|
+
export class ODEmbedManager extends ODManagerWithSafety {
|
|
855
805
|
constructor(debug) {
|
|
856
806
|
super(() => {
|
|
857
|
-
return new ODEmbed("opendiscord:unknown-embed", (instance, params,
|
|
807
|
+
return new ODEmbed("opendiscord:unknown-embed", (instance, params, origin, cancel) => {
|
|
858
808
|
instance.setFooter("opendiscord:unknown-embed");
|
|
859
809
|
instance.setColor("#ff0000");
|
|
860
810
|
instance.setTitle("❌ <ODError:Unknown Embed>");
|
|
@@ -876,13 +826,12 @@ class ODEmbedManager extends base_1.ODManagerWithSafety {
|
|
|
876
826
|
return super.getSafe(id);
|
|
877
827
|
}
|
|
878
828
|
}
|
|
879
|
-
exports.ODEmbedManager = ODEmbedManager;
|
|
880
829
|
/**## ODEmbedInstance `class`
|
|
881
830
|
* This is an Open Discord embed instance.
|
|
882
831
|
*
|
|
883
832
|
* It contains all properties & functions to build an embed!
|
|
884
833
|
*/
|
|
885
|
-
class ODEmbedInstance {
|
|
834
|
+
export class ODEmbedInstance {
|
|
886
835
|
/**The current data of this embed */
|
|
887
836
|
data = {
|
|
888
837
|
title: null,
|
|
@@ -947,9 +896,9 @@ class ODEmbedInstance {
|
|
|
947
896
|
//TEMP CHECKS
|
|
948
897
|
fields.forEach((field, index) => {
|
|
949
898
|
if (field.value.length >= 1024)
|
|
950
|
-
throw new
|
|
899
|
+
throw new ODSystemError("ODEmbed:setFields() => field " + index + " reached 1024 character limit!");
|
|
951
900
|
if (field.name.length >= 256)
|
|
952
|
-
throw new
|
|
901
|
+
throw new ODSystemError("ODEmbed:setFields() => field " + index + " reached 256 name character limit!");
|
|
953
902
|
});
|
|
954
903
|
this.data.fields = fields;
|
|
955
904
|
return this;
|
|
@@ -959,9 +908,9 @@ class ODEmbedInstance {
|
|
|
959
908
|
//TEMP CHECKS
|
|
960
909
|
fields.forEach((field, index) => {
|
|
961
910
|
if (field.value.length >= 1024)
|
|
962
|
-
throw new
|
|
911
|
+
throw new ODSystemError("ODEmbed:addFields() => field " + index + " reached 1024 character limit!");
|
|
963
912
|
if (field.name.length >= 256)
|
|
964
|
-
throw new
|
|
913
|
+
throw new ODSystemError("ODEmbed:addFields() => field " + index + " reached 256 name character limit!");
|
|
965
914
|
});
|
|
966
915
|
this.data.fields.push(...fields);
|
|
967
916
|
return this;
|
|
@@ -977,7 +926,6 @@ class ODEmbedInstance {
|
|
|
977
926
|
return this;
|
|
978
927
|
}
|
|
979
928
|
}
|
|
980
|
-
exports.ODEmbedInstance = ODEmbedInstance;
|
|
981
929
|
/**## ODEmbed `class`
|
|
982
930
|
* This is an Open Discord embed builder.
|
|
983
931
|
*
|
|
@@ -986,16 +934,16 @@ exports.ODEmbedInstance = ODEmbedInstance;
|
|
|
986
934
|
*
|
|
987
935
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
988
936
|
*/
|
|
989
|
-
class ODEmbed extends ODBuilderImplementation {
|
|
937
|
+
export class ODEmbed extends ODBuilderImplementation {
|
|
990
938
|
/**Build this embed & compile it for discord.js */
|
|
991
|
-
async build(
|
|
939
|
+
async build(origin, params) {
|
|
992
940
|
if (this.didCache && this.cache && this.allowCache)
|
|
993
941
|
return this.cache;
|
|
994
942
|
try {
|
|
995
943
|
//create instance
|
|
996
944
|
const instance = new ODEmbedInstance();
|
|
997
945
|
//wait for workers to finish
|
|
998
|
-
await this.workers.executeWorkers(instance,
|
|
946
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
999
947
|
//create the discord.js embed
|
|
1000
948
|
const embed = new discord.EmbedBuilder();
|
|
1001
949
|
if (instance.data.title)
|
|
@@ -1030,13 +978,12 @@ class ODEmbed extends ODBuilderImplementation {
|
|
|
1030
978
|
return { id: this.id, embed };
|
|
1031
979
|
}
|
|
1032
980
|
catch (err) {
|
|
1033
|
-
process.emit("uncaughtException", new
|
|
981
|
+
process.emit("uncaughtException", new ODSystemError("ODEmbed:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
1034
982
|
process.emit("uncaughtException", err);
|
|
1035
983
|
return { id: this.id, embed: null };
|
|
1036
984
|
}
|
|
1037
985
|
}
|
|
1038
986
|
}
|
|
1039
|
-
exports.ODEmbed = ODEmbed;
|
|
1040
987
|
/**## ODQuickEmbed `class`
|
|
1041
988
|
* This is an Open Discord quick embed builder.
|
|
1042
989
|
*
|
|
@@ -1045,13 +992,13 @@ exports.ODEmbed = ODEmbed;
|
|
|
1045
992
|
*
|
|
1046
993
|
* Because of the quick functionality, these embeds are less customisable by other plugins.
|
|
1047
994
|
*/
|
|
1048
|
-
class ODQuickEmbed {
|
|
995
|
+
export class ODQuickEmbed {
|
|
1049
996
|
/**The id of this embed. */
|
|
1050
997
|
id;
|
|
1051
998
|
/**The current data of this embed */
|
|
1052
999
|
data;
|
|
1053
1000
|
constructor(id, data) {
|
|
1054
|
-
this.id = new
|
|
1001
|
+
this.id = new ODId(id);
|
|
1055
1002
|
this.data = data;
|
|
1056
1003
|
}
|
|
1057
1004
|
/**Build this embed & compile it for discord.js */
|
|
@@ -1089,13 +1036,12 @@ class ODQuickEmbed {
|
|
|
1089
1036
|
return { id: this.id, embed };
|
|
1090
1037
|
}
|
|
1091
1038
|
catch (err) {
|
|
1092
|
-
process.emit("uncaughtException", new
|
|
1039
|
+
process.emit("uncaughtException", new ODSystemError("ODQuickEmbed:build(\"" + this.id.value + "\") => Major Error (see next error)"));
|
|
1093
1040
|
process.emit("uncaughtException", err);
|
|
1094
1041
|
return { id: this.id, embed: null };
|
|
1095
1042
|
}
|
|
1096
1043
|
}
|
|
1097
1044
|
}
|
|
1098
|
-
exports.ODQuickEmbed = ODQuickEmbed;
|
|
1099
1045
|
/**## ODMessageManager `class`
|
|
1100
1046
|
* This is an Open Discord message manager.
|
|
1101
1047
|
*
|
|
@@ -1103,10 +1049,10 @@ exports.ODQuickEmbed = ODQuickEmbed;
|
|
|
1103
1049
|
*
|
|
1104
1050
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
1105
1051
|
*/
|
|
1106
|
-
class ODMessageManager extends
|
|
1052
|
+
export class ODMessageManager extends ODManagerWithSafety {
|
|
1107
1053
|
constructor(debug) {
|
|
1108
1054
|
super(() => {
|
|
1109
|
-
return new ODMessage("opendiscord:unknown-message", (instance, params,
|
|
1055
|
+
return new ODMessage("opendiscord:unknown-message", (instance, params, origin, cancel) => {
|
|
1110
1056
|
instance.setContent("**❌ <ODError:Unknown Message>**\nCouldn't find message in registery `opendiscord.builders.messages`");
|
|
1111
1057
|
cancel();
|
|
1112
1058
|
});
|
|
@@ -1125,13 +1071,12 @@ class ODMessageManager extends base_1.ODManagerWithSafety {
|
|
|
1125
1071
|
return super.getSafe(id);
|
|
1126
1072
|
}
|
|
1127
1073
|
}
|
|
1128
|
-
exports.ODMessageManager = ODMessageManager;
|
|
1129
1074
|
/**## ODMessageInstance `class`
|
|
1130
1075
|
* This is an Open Discord message instance.
|
|
1131
1076
|
*
|
|
1132
1077
|
* It contains all properties & functions to build a message!
|
|
1133
1078
|
*/
|
|
1134
|
-
class ODMessageInstance {
|
|
1079
|
+
export class ODMessageInstance {
|
|
1135
1080
|
/**The current data of this message */
|
|
1136
1081
|
data = {
|
|
1137
1082
|
content: null,
|
|
@@ -1169,14 +1114,14 @@ class ODMessageInstance {
|
|
|
1169
1114
|
}
|
|
1170
1115
|
/**Remove an embed from this message */
|
|
1171
1116
|
removeEmbed(id) {
|
|
1172
|
-
const index = this.data.embeds.findIndex((embed) => embed.id.value === new
|
|
1117
|
+
const index = this.data.embeds.findIndex((embed) => embed.id.value === new ODId(id).value);
|
|
1173
1118
|
if (index > -1)
|
|
1174
1119
|
this.data.embeds.splice(index, 1);
|
|
1175
1120
|
return this;
|
|
1176
1121
|
}
|
|
1177
1122
|
/**Get an embed from this message */
|
|
1178
1123
|
getEmbed(id) {
|
|
1179
|
-
const embed = this.data.embeds.find((embed) => embed.id.value === new
|
|
1124
|
+
const embed = this.data.embeds.find((embed) => embed.id.value === new ODId(id).value);
|
|
1180
1125
|
if (embed)
|
|
1181
1126
|
return embed.embed;
|
|
1182
1127
|
else
|
|
@@ -1194,14 +1139,14 @@ class ODMessageInstance {
|
|
|
1194
1139
|
}
|
|
1195
1140
|
/**Remove a component from this message */
|
|
1196
1141
|
removeComponent(id) {
|
|
1197
|
-
const index = this.data.components.findIndex((component) => component.id.value === new
|
|
1142
|
+
const index = this.data.components.findIndex((component) => component.id.value === new ODId(id).value);
|
|
1198
1143
|
if (index > -1)
|
|
1199
1144
|
this.data.components.splice(index, 1);
|
|
1200
1145
|
return this;
|
|
1201
1146
|
}
|
|
1202
1147
|
/**Get a component from this message */
|
|
1203
1148
|
getComponent(id) {
|
|
1204
|
-
const component = this.data.components.find((component) => component.id.value === new
|
|
1149
|
+
const component = this.data.components.find((component) => component.id.value === new ODId(id).value);
|
|
1205
1150
|
if (component)
|
|
1206
1151
|
return component.component;
|
|
1207
1152
|
else
|
|
@@ -1219,21 +1164,20 @@ class ODMessageInstance {
|
|
|
1219
1164
|
}
|
|
1220
1165
|
/**Remove a file from this message */
|
|
1221
1166
|
removeFile(id) {
|
|
1222
|
-
const index = this.data.files.findIndex((file) => file.id.value === new
|
|
1167
|
+
const index = this.data.files.findIndex((file) => file.id.value === new ODId(id).value);
|
|
1223
1168
|
if (index > -1)
|
|
1224
1169
|
this.data.files.splice(index, 1);
|
|
1225
1170
|
return this;
|
|
1226
1171
|
}
|
|
1227
1172
|
/**Get a file from this message */
|
|
1228
1173
|
getFile(id) {
|
|
1229
|
-
const file = this.data.files.find((file) => file.id.value === new
|
|
1174
|
+
const file = this.data.files.find((file) => file.id.value === new ODId(id).value);
|
|
1230
1175
|
if (file)
|
|
1231
1176
|
return file.file;
|
|
1232
1177
|
else
|
|
1233
1178
|
return null;
|
|
1234
1179
|
}
|
|
1235
1180
|
}
|
|
1236
|
-
exports.ODMessageInstance = ODMessageInstance;
|
|
1237
1181
|
/**## ODMessage `class`
|
|
1238
1182
|
* This is an Open Discord message builder.
|
|
1239
1183
|
*
|
|
@@ -1242,15 +1186,15 @@ exports.ODMessageInstance = ODMessageInstance;
|
|
|
1242
1186
|
*
|
|
1243
1187
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
1244
1188
|
*/
|
|
1245
|
-
class ODMessage extends ODBuilderImplementation {
|
|
1189
|
+
export class ODMessage extends ODBuilderImplementation {
|
|
1246
1190
|
/**Build this message & compile it for discord.js */
|
|
1247
|
-
async build(
|
|
1191
|
+
async build(origin, params) {
|
|
1248
1192
|
if (this.didCache && this.cache && this.allowCache)
|
|
1249
1193
|
return this.cache;
|
|
1250
1194
|
//create instance
|
|
1251
1195
|
const instance = new ODMessageInstance();
|
|
1252
1196
|
//wait for workers to finish
|
|
1253
|
-
await this.workers.executeWorkers(instance,
|
|
1197
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
1254
1198
|
//create the discord.js message
|
|
1255
1199
|
const componentArray = [];
|
|
1256
1200
|
let currentRow = new discord.ActionRowBuilder();
|
|
@@ -1305,7 +1249,6 @@ class ODMessage extends ODBuilderImplementation {
|
|
|
1305
1249
|
return result;
|
|
1306
1250
|
}
|
|
1307
1251
|
}
|
|
1308
|
-
exports.ODMessage = ODMessage;
|
|
1309
1252
|
/**## ODQuickMessage `class`
|
|
1310
1253
|
* This is an Open Discord quick message builder.
|
|
1311
1254
|
*
|
|
@@ -1314,13 +1257,13 @@ exports.ODMessage = ODMessage;
|
|
|
1314
1257
|
*
|
|
1315
1258
|
* Because of the quick functionality, these messages are less customisable by other plugins.
|
|
1316
1259
|
*/
|
|
1317
|
-
class ODQuickMessage {
|
|
1260
|
+
export class ODQuickMessage {
|
|
1318
1261
|
/**The id of this message. */
|
|
1319
1262
|
id;
|
|
1320
1263
|
/**The current data of this message. */
|
|
1321
1264
|
data;
|
|
1322
1265
|
constructor(id, data) {
|
|
1323
|
-
this.id = new
|
|
1266
|
+
this.id = new ODId(id);
|
|
1324
1267
|
this.data = data;
|
|
1325
1268
|
}
|
|
1326
1269
|
/**Build this message & compile it for discord.js */
|
|
@@ -1377,7 +1320,6 @@ class ODQuickMessage {
|
|
|
1377
1320
|
return result;
|
|
1378
1321
|
}
|
|
1379
1322
|
}
|
|
1380
|
-
exports.ODQuickMessage = ODQuickMessage;
|
|
1381
1323
|
/**## ODModalManager `class`
|
|
1382
1324
|
* This is an Open Discord modal manager.
|
|
1383
1325
|
*
|
|
@@ -1385,10 +1327,10 @@ exports.ODQuickMessage = ODQuickMessage;
|
|
|
1385
1327
|
*
|
|
1386
1328
|
* It's recommended to use this system in combination with all the other Open Discord builders!
|
|
1387
1329
|
*/
|
|
1388
|
-
class ODModalManager extends
|
|
1330
|
+
export class ODModalManager extends ODManagerWithSafety {
|
|
1389
1331
|
constructor(debug) {
|
|
1390
1332
|
super(() => {
|
|
1391
|
-
return new ODModal("opendiscord:unknown-modal", (instance, params,
|
|
1333
|
+
return new ODModal("opendiscord:unknown-modal", (instance, params, origin, cancel) => {
|
|
1392
1334
|
instance.setCustomId("od:unknown-modal");
|
|
1393
1335
|
instance.setTitle("❌ <ODError:Unknown Modal>");
|
|
1394
1336
|
instance.setQuestions({
|
|
@@ -1414,13 +1356,12 @@ class ODModalManager extends base_1.ODManagerWithSafety {
|
|
|
1414
1356
|
return super.getSafe(id);
|
|
1415
1357
|
}
|
|
1416
1358
|
}
|
|
1417
|
-
exports.ODModalManager = ODModalManager;
|
|
1418
1359
|
/**## ODModalInstance `class`
|
|
1419
1360
|
* This is an Open Discord modal instance.
|
|
1420
1361
|
*
|
|
1421
1362
|
* It contains all properties & functions to build a modal!
|
|
1422
1363
|
*/
|
|
1423
|
-
class ODModalInstance {
|
|
1364
|
+
export class ODModalInstance {
|
|
1424
1365
|
/**The current data of this modal */
|
|
1425
1366
|
data = {
|
|
1426
1367
|
customId: "",
|
|
@@ -1463,7 +1404,6 @@ class ODModalInstance {
|
|
|
1463
1404
|
return null;
|
|
1464
1405
|
}
|
|
1465
1406
|
}
|
|
1466
|
-
exports.ODModalInstance = ODModalInstance;
|
|
1467
1407
|
/**## ODModal `class`
|
|
1468
1408
|
* This is an Open Discord modal builder.
|
|
1469
1409
|
*
|
|
@@ -1472,15 +1412,15 @@ exports.ODModalInstance = ODModalInstance;
|
|
|
1472
1412
|
*
|
|
1473
1413
|
* This is possible by using "workers" or multiple functions that will be executed in priority order!
|
|
1474
1414
|
*/
|
|
1475
|
-
class ODModal extends ODBuilderImplementation {
|
|
1415
|
+
export class ODModal extends ODBuilderImplementation {
|
|
1476
1416
|
/**Build this modal & compile it for discord.js */
|
|
1477
|
-
async build(
|
|
1417
|
+
async build(origin, params) {
|
|
1478
1418
|
if (this.didCache && this.cache && this.allowCache)
|
|
1479
1419
|
return this.cache;
|
|
1480
1420
|
//create instance
|
|
1481
1421
|
const instance = new ODModalInstance();
|
|
1482
1422
|
//wait for workers to finish
|
|
1483
|
-
await this.workers.executeWorkers(instance,
|
|
1423
|
+
await this.workers.executeWorkers(instance, origin, params);
|
|
1484
1424
|
//create the discord.js modal
|
|
1485
1425
|
const modal = new discord.ModalBuilder();
|
|
1486
1426
|
modal.setCustomId(instance.data.customId);
|
|
@@ -1510,4 +1450,3 @@ class ODModal extends ODBuilderImplementation {
|
|
|
1510
1450
|
return { id: this.id, modal };
|
|
1511
1451
|
}
|
|
1512
1452
|
}
|
|
1513
|
-
exports.ODModal = ODModal;
|