@mostfeatured/dbi 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +4 -0
  2. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -1
  3. package/dist/src/types/Components/HTMLComponentsV2/index.js +40 -5
  4. package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -1
  5. package/dist/src/types/Event.d.ts +21 -13
  6. package/dist/src/types/Event.d.ts.map +1 -1
  7. package/dist/src/types/Event.js.map +1 -1
  8. package/dist/test/index.js +1 -1
  9. package/dist/test/index.js.map +1 -1
  10. package/generated/namespaceData.d.ts +3 -1
  11. package/package.json +6 -2
  12. package/.gitattributes +0 -2
  13. package/.hintrc +0 -8
  14. package/.vscode/settings.json +0 -3
  15. package/docs/ADVANCED_FEATURES.md +0 -840
  16. package/docs/API_REFERENCE.md +0 -929
  17. package/docs/CHAT_INPUT.md +0 -811
  18. package/docs/COMPONENTS.md +0 -1039
  19. package/docs/EVENTS.md +0 -568
  20. package/docs/GETTING_STARTED.md +0 -398
  21. package/docs/LOCALIZATION.md +0 -777
  22. package/docs/README.md +0 -345
  23. package/docs/SVELTE_COMPONENTS.md +0 -1111
  24. package/docs/llm/ADVANCED_FEATURES.txt +0 -521
  25. package/docs/llm/API_REFERENCE.txt +0 -659
  26. package/docs/llm/CHAT_INPUT.txt +0 -514
  27. package/docs/llm/COMPONENTS.txt +0 -595
  28. package/docs/llm/EVENTS.txt +0 -449
  29. package/docs/llm/GETTING_STARTED.txt +0 -296
  30. package/docs/llm/LOCALIZATION.txt +0 -501
  31. package/docs/llm/README.txt +0 -193
  32. package/docs/llm/SVELTE_COMPONENTS.txt +0 -566
  33. package/src/DBI.ts +0 -1007
  34. package/src/Events.ts +0 -189
  35. package/src/data/eventMap.json +0 -248
  36. package/src/index.ts +0 -23
  37. package/src/methods/handleMessageCommands.ts +0 -482
  38. package/src/methods/hookEventListeners.ts +0 -119
  39. package/src/methods/hookInteractionListeners.ts +0 -314
  40. package/src/methods/publishInteractions.ts +0 -256
  41. package/src/types/ApplicationRoleConnectionMetadata.ts +0 -19
  42. package/src/types/Builders/ButtonBuilder.ts +0 -53
  43. package/src/types/Builders/ChannelSelectMenuBuilder.ts +0 -53
  44. package/src/types/Builders/MentionableSelectMenuBuilder.ts +0 -53
  45. package/src/types/Builders/ModalBuilder.ts +0 -53
  46. package/src/types/Builders/RoleSelectMenuBuilder.ts +0 -53
  47. package/src/types/Builders/StringSelectMenuBuilder.ts +0 -53
  48. package/src/types/Builders/UserSelectMenuBuilder.ts +0 -53
  49. package/src/types/ChatInput/ChatInput.ts +0 -28
  50. package/src/types/ChatInput/ChatInputOptions.ts +0 -388
  51. package/src/types/Components/Button.ts +0 -39
  52. package/src/types/Components/ChannelSelectMenu.ts +0 -43
  53. package/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.ts +0 -78
  54. package/src/types/Components/HTMLComponentsV2/index.ts +0 -761
  55. package/src/types/Components/HTMLComponentsV2/parser.ts +0 -649
  56. package/src/types/Components/HTMLComponentsV2/svelteParser.ts +0 -1503
  57. package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +0 -416
  58. package/src/types/Components/MentionableSelectMenu.ts +0 -43
  59. package/src/types/Components/Modal.ts +0 -46
  60. package/src/types/Components/RoleSelectMenu.ts +0 -43
  61. package/src/types/Components/StringSelectMenu.ts +0 -43
  62. package/src/types/Components/UserSelectMenu.ts +0 -43
  63. package/src/types/Event.ts +0 -145
  64. package/src/types/Interaction.ts +0 -100
  65. package/src/types/other/CustomEvent.ts +0 -19
  66. package/src/types/other/FakeMessageInteraction.ts +0 -408
  67. package/src/types/other/InteractionLocale.ts +0 -34
  68. package/src/types/other/Locale.ts +0 -70
  69. package/src/types/other/MessageContextMenu.ts +0 -27
  70. package/src/types/other/UserContextMenu.ts +0 -25
  71. package/src/utils/MemoryStore.ts +0 -28
  72. package/src/utils/UtilTypes.ts +0 -11
  73. package/src/utils/customId.ts +0 -49
  74. package/src/utils/permissions.ts +0 -5
  75. package/src/utils/recursiveImport.ts +0 -35
  76. package/src/utils/recursiveUnload.ts +0 -25
  77. package/src/utils/unloadModule.ts +0 -7
  78. package/test/index.ts +0 -176
  79. package/test/product-showcase.svelte +0 -558
  80. package/test/test.ts +0 -3
  81. package/tsconfig.json +0 -51
@@ -1,482 +0,0 @@
1
- import {
2
- ApplicationCommandType,
3
- ChatInputCommandInteraction,
4
- Message,
5
- MessagePayload,
6
- ApplicationCommandOptionType,
7
- } from "discord.js";
8
- import { NamespaceEnums } from "../../generated/namespaceData";
9
- import { DBI } from "../DBI";
10
- import { FakeMessageInteraction } from "../types/other/FakeMessageInteraction";
11
- import { TDBILocaleString } from "../types/other/Locale";
12
-
13
- const INTEGER_REGEX = /^-?\d+$/;
14
- const NUMBER_REGEX = /^-?\d+(?:\.\d+)?$/;
15
-
16
- export type TDBIMessageCommandArgumentErrorTypes =
17
- | "MissingRequiredOption"
18
- | "MinLength"
19
- | "MaxLength"
20
- | "InvalidChoice"
21
- | "InvalidInteger"
22
- | "MinInteger"
23
- | "MaxInteger"
24
- | "InvalidNumber"
25
- | "MinNumber"
26
- | "MaxNumber"
27
- | "InvalidBoolean"
28
- | "InvalidUser"
29
- | "InvalidChannel"
30
- | "InvalidRole"
31
- | "InvalidMentionable"
32
- | "InvalidCompleteChoice";
33
-
34
- export async function handleMessageCommands(
35
- dbi: DBI<NamespaceEnums>,
36
- message: Message
37
- ) {
38
- const chatInputs = dbi.data.interactions.filter(
39
- (i) => i.type === "ChatInput"
40
- );
41
- const prefixes = await dbi.config.messageCommands.prefixes({ message });
42
- if (!prefixes?.length) return;
43
- const content = message.content;
44
- const usedPrefix = prefixes.find((p) => content.startsWith(p));
45
- if (!usedPrefix) return;
46
- const contentWithoutPrefix = content.slice(usedPrefix?.length ?? 0);
47
- const contentLower = contentWithoutPrefix.toLowerCase();
48
-
49
- let locale: string =
50
- message.guild.preferredLocale?.split("-")?.at(0) ||
51
- (dbi.config.defaults.locale as any);
52
- let usedAlias: string | undefined;
53
- let chatInput = chatInputs.find((i) => {
54
- let found = contentLower.startsWith(i.name);
55
- if (found) return true;
56
- let alias = i.other?.messageCommand?.aliases?.find((a) =>
57
- contentLower.startsWith(a)
58
- );
59
- if (alias) {
60
- usedAlias = alias;
61
- return true;
62
- }
63
- return false;
64
- });
65
- let commandName = usedAlias ?? chatInput?.name;
66
-
67
- if (!chatInput) {
68
- fLoop: for (const [localeInterName, localeData] of dbi.data
69
- .interactionLocales) {
70
- for (const [localeName, translation] of Object.entries(
71
- localeData.data || {}
72
- )) {
73
- if (contentLower.startsWith(translation.name)) {
74
- commandName = translation.name;
75
- locale = localeName;
76
- chatInput = chatInputs.find((i) => i.name === localeData.name);
77
- break fLoop;
78
- }
79
- }
80
- }
81
- }
82
-
83
- if (!chatInput || chatInput.other?.messageCommand?.ignore) return;
84
-
85
- const interaction = new FakeMessageInteraction(
86
- dbi,
87
- message,
88
- chatInput as any,
89
- locale,
90
- commandName,
91
- usedPrefix
92
- );
93
-
94
- const builtLocale = {
95
- user:
96
- dbi.data.locales.get(interaction.locale) ||
97
- dbi.data.locales.get(dbi.config.defaults.locale.name),
98
- guild: message.guild?.preferredLocale
99
- ? dbi.data.locales.get(
100
- message.guild?.preferredLocale?.split("-")?.at(0)
101
- ) || dbi.data.locales.get(dbi.config.defaults.locale.name)
102
- : null,
103
- };
104
-
105
- const { defaultMemberPermissions, directMessages } = chatInput as any;
106
-
107
- if (typeof directMessages !== "undefined" && !directMessages && !message.guild) {
108
- const res = await dbi.events.trigger(
109
- "messageCommandDirectMessageUsageError", {
110
- interaction,
111
- message,
112
- locale: builtLocale,
113
- dbiInteraction: chatInput
114
- });
115
- if (!res) return;
116
- }
117
-
118
- if (Array.isArray(defaultMemberPermissions) && message.guild && message.member) {
119
- const perms = message.member.permissions.toArray();
120
- if (!defaultMemberPermissions.every((p) => perms.includes(p))) {
121
- const res = await dbi.events.trigger(
122
- "messageCommandDefaultMemberPermissionsError", {
123
- interaction,
124
- message,
125
- locale: builtLocale,
126
- dbiInteraction: chatInput,
127
- permissions: defaultMemberPermissions
128
- });
129
- if (!res) return;
130
- }
131
- }
132
-
133
- if (chatInput.options.length) {
134
- let errorType: TDBIMessageCommandArgumentErrorTypes;
135
- let lastOption: any;
136
- let lastValue: any;
137
- let lastExtra: any;
138
- let lastIndex: number;
139
- for (let i = 0; i < chatInput.options.length; i++) {
140
- lastIndex = i;
141
- const option: any = interaction.dbiChatInputOptions[i];
142
- const value = interaction.parsedArgs.get(option.name)?.value;
143
-
144
- lastOption = option;
145
- lastValue = value;
146
-
147
- switch (option.type) {
148
- case ApplicationCommandOptionType.String: {
149
- if (!option.required && !value) break;
150
-
151
- if (option.autocomplete && option.onComplete) {
152
- let choices = await option.onComplete({
153
- interaction,
154
- value,
155
- });
156
- if (!choices.length)
157
- choices = await option.onComplete({
158
- interaction,
159
- value: "",
160
- });
161
- if (choices.length > 20)
162
- throw new Error("Autocomplete returned more than 20 choices.");
163
- lastExtra = choices;
164
- if (!choices.find((c) => c.name === value || c.value === value)) {
165
- if (value) {
166
- errorType = "InvalidCompleteChoice";
167
- break;
168
- } else if (option.required && !value) {
169
- errorType = "MissingRequiredOption";
170
- break;
171
- }
172
- }
173
- option._choices = choices;
174
- }
175
-
176
- if (option.choices) {
177
- const localeData = dbi.data.interactionLocales.get(
178
- chatInput.name
179
- )?.data;
180
- const choicesLocaleData =
181
- localeData?.[locale as TDBILocaleString]?.options?.[option.name]
182
- ?.choices;
183
- if (
184
- !option.choices.find(
185
- (c) =>
186
- c.name === value ||
187
- c.value === value ||
188
- (choicesLocaleData?.[c.value] &&
189
- choicesLocaleData?.[c.value] === value)
190
- )
191
- ) {
192
- lastExtra = option.choices.map((c) => ({
193
- name: choicesLocaleData?.[c.value] ?? c.name,
194
- value: c.value,
195
- }));
196
- if (value) {
197
- errorType = "InvalidChoice";
198
- break;
199
- } else if (option.required && !value) {
200
- errorType = "MissingRequiredOption";
201
- break;
202
- }
203
- }
204
- break;
205
- }
206
-
207
- if (option.required && !value) {
208
- errorType = "MissingRequiredOption";
209
- break;
210
- }
211
- if (option.minLength && value?.length < option.minLength) {
212
- errorType = "MinLength";
213
- break;
214
- }
215
- if (option.maxLength && value?.length > option.maxLength) {
216
- errorType = "MaxLength";
217
- break;
218
- }
219
-
220
- break;
221
- }
222
- case ApplicationCommandOptionType.Integer: {
223
- if (!option.required && !value) break;
224
-
225
- let parsedInt = parseInt(value);
226
-
227
- if (option.autocomplete && option.onComplete) {
228
- let choices = await option.onComplete({
229
- interaction,
230
- value,
231
- });
232
- if (!choices.length)
233
- choices = await option.onComplete({
234
- interaction,
235
- value: "",
236
- });
237
- if (choices.length > 20)
238
- throw new Error("Autocomplete returned more than 20 choices.");
239
- lastExtra = choices;
240
- if (
241
- !choices.find((c) => c.value === parsedInt || c.name === value)
242
- ) {
243
- if (value) {
244
- errorType = "InvalidCompleteChoice";
245
- break;
246
- } else if (option.required && !value) {
247
- errorType = "MissingRequiredOption";
248
- break;
249
- }
250
- }
251
- option._choices = choices;
252
- break;
253
- }
254
-
255
- if (option.choices) {
256
- const localeData = dbi.data.interactionLocales.get(
257
- chatInput.name
258
- )?.data;
259
- const choicesLocaleData =
260
- localeData?.[locale as TDBILocaleString]?.options?.[option.name]
261
- ?.choices;
262
- if (
263
- !option.choices.find(
264
- (c) =>
265
- c.value === parsedInt ||
266
- c.name === value ||
267
- (choicesLocaleData?.[c.value] &&
268
- choicesLocaleData?.[c.value] === value)
269
- )
270
- ) {
271
- lastExtra = option.choices.map((c) => ({
272
- name: choicesLocaleData?.[c.value] ?? c.name,
273
- value: c.value,
274
- }));
275
- if (value) {
276
- errorType = "InvalidChoice";
277
- break;
278
- } else if (option.required && !value) {
279
- errorType = "MissingRequiredOption";
280
- break;
281
- }
282
- }
283
- break;
284
- }
285
-
286
- if (!INTEGER_REGEX.test(value)) {
287
- errorType = "InvalidInteger";
288
- break;
289
- }
290
-
291
- if (option.minValue && parsedInt < option.minValue) {
292
- errorType = "MinInteger";
293
- break;
294
- }
295
-
296
- if (option.maxValue && parsedInt > option.maxValue) {
297
- errorType = "MaxInteger";
298
- break;
299
- }
300
-
301
- break;
302
- }
303
- case ApplicationCommandOptionType.Number: {
304
- if (!option.required && !value) break;
305
-
306
- let parsedFloat = parseFloat(value);
307
-
308
- if (option.autocomplete && option.onComplete) {
309
- let choices = await option.onComplete({
310
- interaction,
311
- value,
312
- });
313
- if (!choices.length)
314
- choices = await option.onComplete({
315
- interaction,
316
- value: "",
317
- });
318
- if (choices.length > 20)
319
- throw new Error("Autocomplete returned more than 20 choices.");
320
- lastExtra = choices;
321
- if (
322
- !choices.find((c) => c.value === parsedFloat || c.name === value)
323
- ) {
324
- if (value) {
325
- errorType = "InvalidCompleteChoice";
326
- break;
327
- } else if (option.required && !value) {
328
- errorType = "MissingRequiredOption";
329
- break;
330
- }
331
- }
332
- option._choices = choices;
333
- break;
334
- }
335
-
336
- if (option.choices) {
337
- const localeData = dbi.data.interactionLocales.get(
338
- chatInput.name
339
- )?.data;
340
- const choicesLocaleData =
341
- localeData?.[locale as TDBILocaleString]?.options?.[option.name]
342
- ?.choices;
343
- if (
344
- !option.choices.find(
345
- (c) =>
346
- c.value === parsedFloat ||
347
- c.name === value ||
348
- (choicesLocaleData?.[c.value] &&
349
- choicesLocaleData?.[c.value] === value)
350
- )
351
- ) {
352
- lastExtra = option.choices.map((c) => ({
353
- name: choicesLocaleData?.[c.value] ?? c.name,
354
- value: c.value,
355
- }));
356
- if (value) {
357
- errorType = "InvalidChoice";
358
- break;
359
- } else if (option.required && !value) {
360
- errorType = "MissingRequiredOption";
361
- break;
362
- }
363
- }
364
- break;
365
- }
366
-
367
- if (!NUMBER_REGEX.test(value)) {
368
- errorType = "InvalidNumber";
369
- break;
370
- }
371
-
372
- if (option.minValue && parsedFloat < option.minValue) {
373
- errorType = "MinNumber";
374
- break;
375
- }
376
-
377
- if (option.maxValue && parsedFloat > option.maxValue) {
378
- errorType = "MaxNumber";
379
- break;
380
- }
381
- break;
382
- }
383
- case ApplicationCommandOptionType.Boolean: {
384
- let boolKeys = Object.keys(
385
- dbi.config.messageCommands.typeAliases.booleans
386
- );
387
- if (option.required && !boolKeys.includes(value?.toLowerCase?.())) {
388
- errorType = "InvalidBoolean";
389
- break;
390
- }
391
- break;
392
- }
393
- case ApplicationCommandOptionType.User: {
394
- await message.client.users
395
- .fetch(interaction.options.getUserId(option.name))
396
- .catch(() => { });
397
- if (option.required && !interaction.options.getUser(option.name)) {
398
- errorType = "InvalidUser";
399
- break;
400
- }
401
- break;
402
- }
403
- case ApplicationCommandOptionType.Channel: {
404
- await message.client.channels
405
- .fetch(interaction.options.getChannelId(option.name))
406
- .catch(() => { });
407
- if (
408
- option.required &&
409
- !interaction.options.getChannel(
410
- option.name,
411
- null,
412
- option.channelTypes
413
- )
414
- ) {
415
- errorType = "InvalidChannel";
416
- break;
417
- }
418
- break;
419
- }
420
- case ApplicationCommandOptionType.Role: {
421
- await message.guild.roles
422
- .fetch(interaction.options.getRoleId(option.name))
423
- .catch(() => { });
424
- if (option.required && !interaction.options.getRole(option.name)) {
425
- errorType = "InvalidRole";
426
- break;
427
- }
428
- break;
429
- }
430
- case ApplicationCommandOptionType.Mentionable: {
431
- let mentionableId = interaction.options.getMentionableId(option.name);
432
- await message.guild.roles.fetch(mentionableId).catch(() => { });
433
- await message.client.channels.fetch(mentionableId).catch(() => { });
434
- await message.client.users.fetch(mentionableId).catch(() => { });
435
- if (
436
- option.required &&
437
- !interaction.options.getMentionable(option.name)
438
- ) {
439
- errorType = "InvalidMentionable";
440
- break;
441
- }
442
- break;
443
- }
444
- case ApplicationCommandOptionType.Attachment: {
445
- if (option.required && !value) {
446
- errorType = "MissingRequiredOption";
447
- }
448
- break;
449
- }
450
- }
451
-
452
- if (errorType) {
453
- break;
454
- } else {
455
- lastExtra = null;
456
- lastIndex = null;
457
- lastOption = null;
458
- lastValue = null;
459
- }
460
- }
461
-
462
- if (errorType) {
463
- let res = await dbi.events.trigger("messageCommandArgumentError", {
464
- interaction,
465
- message,
466
- locale: builtLocale,
467
- error: {
468
- type: errorType,
469
- option: lastOption,
470
- extra: lastExtra,
471
- index: lastIndex,
472
- },
473
- value: lastValue,
474
- dbiInteraction: chatInput,
475
- });
476
- if (!res) return;
477
- }
478
- }
479
-
480
- interaction.init();
481
- dbi.data.clients.first().client.emit("interactionCreate", interaction as any);
482
- }
@@ -1,119 +0,0 @@
1
- import { Guild } from "discord.js";
2
- import { NamespaceEnums } from "../../generated/namespaceData";
3
- import { DBI } from "../DBI";
4
- import { TDBIEventOrder } from "../types/Event";
5
-
6
- export function hookEventListeners(dbi: DBI<NamespaceEnums>): () => any {
7
-
8
- function getClientByEvent(value) {
9
- return value.triggerType == "OneByOne"
10
- ? dbi.data.clients.next(`Event:${value.name}`)
11
- : value.triggerType == "OneByOneGlobal"
12
- ? dbi.data.clients.next("Event")
13
- : value.triggerType == "Random"
14
- ? dbi.data.clients.random()
15
- : dbi.data.clients.first();
16
- }
17
-
18
- async function handle(eventName: string, ...args: any[]) {
19
- if (!dbi.data.eventMap[eventName]) return;
20
-
21
- let isDirect = args?.[0]?._DIRECT_ ?? false;
22
- if (isDirect) delete args[0]._DIRECT_;
23
-
24
- let ctxArgs =
25
- isDirect
26
- ? args[0]
27
- : (dbi.data.eventMap[eventName] as any).reduce((all, current, index) => {
28
- all[current] = args[index];
29
- return all;
30
- }, {});
31
-
32
- let other = {};
33
-
34
- let guildLocaleName = args.reduce((all, current) => {
35
- if (current?.guild?.id) return current?.guild?.preferredLocale?.split?.("-")?.[0];
36
- if (current instanceof Guild) return current?.preferredLocale?.split?.("-")?.[0];
37
- return all;
38
- }, null);
39
- let guildLocale = guildLocaleName ? (dbi.data.locales.has(guildLocaleName) ? dbi.data.locales.get(guildLocaleName) : dbi.data.locales.get(dbi.config.defaults.locale.name)) : null;
40
-
41
- let locale = guildLocale ? { guild: guildLocale } : null;
42
-
43
-
44
- let awaitedEvents = [];
45
- let unAwaitedEvents = [];
46
- for (let i = 0; i < dbi.data.events.size; i++) {
47
- const value = dbi.data.events.at(i);
48
- if (value.name == eventName) {
49
- if (value.ordered?.await) {
50
- awaitedEvents.push(value);
51
- } else {
52
- unAwaitedEvents.push(value);
53
- }
54
- }
55
- }
56
-
57
- let arg = { eventName, ...ctxArgs, other, locale };
58
-
59
- for (let i = 0; i < unAwaitedEvents.length; i++) {
60
- const value = unAwaitedEvents[i];
61
-
62
- if (value?.disabled) continue;
63
-
64
- if (value.ordered?.delayBefore) await new Promise(resolve => setTimeout(resolve, value.ordered.delayBefore));
65
-
66
- if (!(await dbi.events.trigger("beforeEvent", { ...arg, dbiEvent: value }))) continue;
67
-
68
- if (dbi.config.strict) {
69
- value.onExecute({ ...arg, nextClient: getClientByEvent(value) });
70
- } else {
71
- try {
72
- value.onExecute({ ...arg, nextClient: getClientByEvent(value) })?.catch(error => {
73
- dbi.events.trigger("eventError", { ...arg, error, dbiEvent: value });
74
- });
75
- } catch (error) {
76
- dbi.events.trigger("eventError", { ...arg, error, dbiEvent: value });
77
- }
78
- }
79
- if (value.ordered?.delayAfter) await new Promise(resolve => setTimeout(resolve, value.ordered.delayAfter));
80
- }
81
-
82
- for (let i = 0; i < awaitedEvents.length; i++) {
83
- const value = awaitedEvents[i];
84
-
85
- if (value?.disabled) continue;
86
-
87
- if (!(await dbi.events.trigger("beforeEvent", { ...arg, dbiEvent: value }))) continue;
88
-
89
- if (value.ordered?.delayBefore) await new Promise(resolve => setTimeout(resolve, value.ordered.delayBefore));
90
-
91
- if (dbi.config.strict) {
92
- await value.onExecute({ ...arg, nextClient: getClientByEvent(value) });
93
- } else {
94
- try {
95
- await value.onExecute({ ...arg, nextClient: getClientByEvent(value) })?.catch(error => {
96
- dbi.events.trigger("eventError", { ...arg, error, dbiEvent: value });
97
- });
98
- } catch (error) {
99
- await dbi.events.trigger("eventError", { ...arg, error, dbiEvent: value });
100
- }
101
- }
102
- if (value.ordered?.delayAfter) await new Promise(resolve => setTimeout(resolve, value.ordered.delayAfter));
103
- }
104
-
105
- dbi.events.trigger("afterEvent", arg)
106
- }
107
-
108
- let firstClient = dbi.data.clients.first().client;
109
- let originalEmit = firstClient.emit;
110
-
111
- firstClient.emit = function (eventName, ...args) {
112
- handle(eventName, ...args);
113
- return originalEmit.call(this, eventName, ...args);
114
- }
115
-
116
- return () => {
117
- firstClient.emit = originalEmit;
118
- }
119
- }