@mostfeatured/dbi 0.1.6 → 0.1.7
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/DBI.d.ts +1 -1
- package/dist/DBI.d.ts.map +1 -1
- package/dist/DBI.js +32 -21
- package/dist/DBI.js.map +1 -1
- package/dist/methods/publishInteractions.js +9 -9
- package/dist/methods/publishInteractions.js.map +1 -1
- package/dist/types/Event.d.ts +1 -0
- package/dist/types/Event.d.ts.map +1 -1
- package/dist/types/Event.js +2 -0
- package/dist/types/Event.js.map +1 -1
- package/dist/types/Interaction.d.ts +4 -8
- package/dist/types/Interaction.d.ts.map +1 -1
- package/dist/types/Interaction.js +3 -8
- package/dist/types/Interaction.js.map +1 -1
- package/dist/types/other/FakeMessageInteraction.js +1 -1
- package/dist/types/other/FakeMessageInteraction.js.map +1 -1
- package/dist/types/other/InteractionLocale.d.ts +1 -0
- package/dist/types/other/InteractionLocale.d.ts.map +1 -1
- package/dist/types/other/InteractionLocale.js +2 -0
- package/dist/types/other/InteractionLocale.js.map +1 -1
- package/dist/types/other/Locale.d.ts +1 -0
- package/dist/types/other/Locale.d.ts.map +1 -1
- package/dist/types/other/Locale.js +2 -0
- package/dist/types/other/Locale.js.map +1 -1
- package/package.json +1 -1
- package/src/DBI.ts +67 -56
- package/src/methods/publishInteractions.ts +8 -8
- package/src/types/Event.ts +2 -0
- package/src/types/Interaction.ts +6 -21
- package/src/types/other/FakeMessageInteraction.ts +1 -1
- package/src/types/other/InteractionLocale.ts +2 -0
- package/src/types/other/Locale.ts +2 -0
- package/tsconfig.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../../src/types/other/Locale.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAiB5B,MAAa,SAAS;IACpB,IAAI,CAAmB;IACvB,IAAI,CAA6C;IACzC,KAAK,CAA2B;IACxC,GAAG,CAAsB;IACzB,YAAY,GAAwB,EAAE,GAAsC;QAC1E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAa,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,WAAW,CAAC,MAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,gBAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAQ,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,WAAW,CAAa,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../../src/types/other/Locale.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAiB5B,MAAa,SAAS;IACpB,IAAI,CAAmB;IACvB,IAAI,CAA6C;IACzC,KAAK,CAA2B;IACxC,GAAG,CAAsB;IACzB,IAAI,CAAoB;IACxB,YAAY,GAAwB,EAAE,GAAsC;QAC1E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAa,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,WAAW,CAAC,MAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,gBAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAQ,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,WAAW,CAAa,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtBD,8BAsBC;AAED,SAAgB,WAAW,CAAoC,IAA8B;IAC3F,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;oBAC9B,OAAO,gBAAM,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;gBAClG,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC,CAAA;AACL,CAAC;AAVD,kCAUC","sourcesContent":["import stuffs from \"stuffs\";\r\nimport { NamespaceData, NamespaceEnums } from \"../../../generated/namespaceData\";\r\nimport { DBI } from \"../../DBI\";\r\n\r\n\r\nexport interface DBILangObject {\r\n [property: string]: DBILangObject & ((...args: any[]) => string);\r\n}\r\n\r\nexport interface DBILangConstructorObject {\r\n [property: string]: DBILangConstructorObject | string;\r\n}\r\n\r\nexport type TDBILocaleString = \"en\" | \"bg\" | \"zh\" | \"hr\" | \"cs\" | \"da\" | \"nl\" | \"fi\" | \"fr\" | \"de\" | \"el\" | \"hi\" | \"hu\" | \"it\" | \"ja\" | \"ko\" | \"no\" | \"pl\" | \"pt\" | \"ro\" | \"ru\" | \"es\" | \"sv\" | \"th\" | \"tr\" | \"uk\" | \"vi\";\r\n\r\nexport type TDBILocaleConstructor<TNamespace extends NamespaceEnums> = Omit<DBILocale<TNamespace>, \"data\" | \"dbi\" | \"mergeLocale\"> & { data: DBILangConstructorObject };\r\n\r\nexport class DBILocale<TNamespace extends NamespaceEnums> {\r\n name: TDBILocaleString;\r\n data: NamespaceData[TNamespace][\"contentLocale\"];\r\n private _data: DBILangConstructorObject;\r\n dbi: DBI<TNamespace, {}>;\r\n flag: string | undefined\r\n constructor(dbi: DBI<TNamespace, {}>, cfg: TDBILocaleConstructor<TNamespace>) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.flag = cfg.flag;\r\n this._data = cfg.data;\r\n this.data = convertLang<TNamespace>(cfg.data);\r\n }\r\n mergeLocale(locale: DBILocale<TNamespace>): DBILocale<TNamespace> {\r\n this._data = stuffs.defaultify(locale._data, this._data, true) as any;\r\n this.data = convertLang<TNamespace>(this._data);\r\n\r\n locale.data = this.data;\r\n locale._data = this._data;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nexport function convertLang<TNamespace extends NamespaceEnums>(data: DBILangConstructorObject): NamespaceData[TNamespace][\"contentLocale\"] {\r\n return Object.fromEntries(Object.entries(data).map(([key, value]) => {\r\n if (typeof value === \"string\") {\r\n return [key, (...args: any[]) => {\r\n return stuffs.mapReplace(value, args.map((t, i) => [new RegExp(`\\\\{${i}(;[^}]+)?\\\\}`, \"g\"), t]))\r\n }];\r\n } else {\r\n return [key, convertLang(value)];\r\n }\r\n }))\r\n}\r\n"]}
|
package/package.json
CHANGED
package/src/DBI.ts
CHANGED
|
@@ -111,15 +111,15 @@ export interface DBIConfig {
|
|
|
111
111
|
|
|
112
112
|
export interface DBIConfigConstructor {
|
|
113
113
|
discord:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
| {
|
|
115
|
+
token: string;
|
|
116
|
+
options: Discord.ClientOptions;
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
namespace: string;
|
|
120
|
+
token: string;
|
|
121
|
+
options: Discord.ClientOptions;
|
|
122
|
+
}[];
|
|
123
123
|
|
|
124
124
|
defaults?: {
|
|
125
125
|
locale?: TDBILocaleString;
|
|
@@ -313,12 +313,12 @@ export class DBI<
|
|
|
313
313
|
config.discord = Array.isArray(config.discord)
|
|
314
314
|
? config.discord
|
|
315
315
|
: [
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
316
|
+
{
|
|
317
|
+
token: config.discord.token,
|
|
318
|
+
options: config.discord.options,
|
|
319
|
+
namespace: "default",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
322
|
|
|
323
323
|
this.data.clients.push(...(config.discord as any));
|
|
324
324
|
for (let clientContext of this.data.clients) {
|
|
@@ -326,9 +326,9 @@ export class DBI<
|
|
|
326
326
|
...((clientContext.options || {}) as any),
|
|
327
327
|
...(config.sharding == "hybrid"
|
|
328
328
|
? {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
shards: Sharding.getInfo().SHARD_LIST,
|
|
330
|
+
shardCount: Sharding.getInfo().TOTAL_SHARDS,
|
|
331
|
+
}
|
|
332
332
|
: {}),
|
|
333
333
|
});
|
|
334
334
|
clientContext.client = client as Discord.Client<true>;
|
|
@@ -412,7 +412,7 @@ export class DBI<
|
|
|
412
412
|
this.data.customEventNames.clear();
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
private async _registerAll() {
|
|
415
|
+
private async _registerAll(flags: string[] = []) {
|
|
416
416
|
const self = this;
|
|
417
417
|
const ChatInputOptions = new DBIChatInputOptions(self);
|
|
418
418
|
|
|
@@ -421,10 +421,11 @@ export class DBI<
|
|
|
421
421
|
let dbiChatInput = new DBIChatInput(self, cfg);
|
|
422
422
|
if (self.data.interactions.has(dbiChatInput.name))
|
|
423
423
|
throw new Error(
|
|
424
|
-
`DBIChatInput "${dbiChatInput.name}" already loaded as "${
|
|
424
|
+
`DBIChatInput "${dbiChatInput.name}" already loaded as "${
|
|
425
|
+
self.data.interactions.get(dbiChatInput.name)?.type
|
|
425
426
|
}"!`
|
|
426
427
|
);
|
|
427
|
-
self.data.interactions.set(dbiChatInput.name, dbiChatInput);
|
|
428
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(dbiChatInput.name, dbiChatInput);
|
|
428
429
|
return dbiChatInput;
|
|
429
430
|
};
|
|
430
431
|
ChatInput = Object.assign(
|
|
@@ -445,7 +446,7 @@ export class DBI<
|
|
|
445
446
|
throw new Error(
|
|
446
447
|
`DBIEvent "${dbiEvent.id || dbiEvent.name}" already loaded!`
|
|
447
448
|
);
|
|
448
|
-
|
|
449
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);
|
|
449
450
|
return dbiEvent;
|
|
450
451
|
};
|
|
451
452
|
Event = Object.assign(
|
|
@@ -461,10 +462,11 @@ export class DBI<
|
|
|
461
462
|
let dbiButton = new DBIButton(self as any, cfg);
|
|
462
463
|
if (self.config.strict && self.data.interactions.has(dbiButton.name))
|
|
463
464
|
throw new Error(
|
|
464
|
-
`DBIButton "${dbiButton.name}" already loaded as "${
|
|
465
|
+
`DBIButton "${dbiButton.name}" already loaded as "${
|
|
466
|
+
self.data.interactions.get(dbiButton.name)?.type
|
|
465
467
|
}"!`
|
|
466
468
|
);
|
|
467
|
-
|
|
469
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(dbiButton.name, dbiButton as any);
|
|
468
470
|
return dbiButton;
|
|
469
471
|
};
|
|
470
472
|
Button = Object.assign(
|
|
@@ -485,11 +487,13 @@ export class DBI<
|
|
|
485
487
|
self.data.interactions.has(dbiStringSelectMenu.name)
|
|
486
488
|
)
|
|
487
489
|
throw new Error(
|
|
488
|
-
`DBIStringSelectMenu "${
|
|
489
|
-
|
|
490
|
+
`DBIStringSelectMenu "${
|
|
491
|
+
dbiStringSelectMenu.name
|
|
492
|
+
}" already loaded as "${
|
|
493
|
+
self.data.interactions.get(dbiStringSelectMenu.name)?.type
|
|
490
494
|
}"!`
|
|
491
495
|
);
|
|
492
|
-
self.data.interactions.set(
|
|
496
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
493
497
|
dbiStringSelectMenu.name,
|
|
494
498
|
dbiStringSelectMenu as any
|
|
495
499
|
);
|
|
@@ -513,10 +517,11 @@ export class DBI<
|
|
|
513
517
|
self.data.interactions.has(dbiUserSelectMenu.name)
|
|
514
518
|
)
|
|
515
519
|
throw new Error(
|
|
516
|
-
`DBIUserSelectMenu "${dbiUserSelectMenu.name}" already loaded as "${
|
|
520
|
+
`DBIUserSelectMenu "${dbiUserSelectMenu.name}" already loaded as "${
|
|
521
|
+
self.data.interactions.get(dbiUserSelectMenu.name)?.type
|
|
517
522
|
}"!`
|
|
518
523
|
);
|
|
519
|
-
self.data.interactions.set(
|
|
524
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
520
525
|
dbiUserSelectMenu.name,
|
|
521
526
|
dbiUserSelectMenu as any
|
|
522
527
|
);
|
|
@@ -540,10 +545,11 @@ export class DBI<
|
|
|
540
545
|
self.data.interactions.has(dbiRoleSelectMenu.name)
|
|
541
546
|
)
|
|
542
547
|
throw new Error(
|
|
543
|
-
`DBIRoleSelectMenu "${dbiRoleSelectMenu.name}" already loaded as "${
|
|
548
|
+
`DBIRoleSelectMenu "${dbiRoleSelectMenu.name}" already loaded as "${
|
|
549
|
+
self.data.interactions.get(dbiRoleSelectMenu.name)?.type
|
|
544
550
|
}"!`
|
|
545
551
|
);
|
|
546
|
-
self.data.interactions.set(
|
|
552
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
547
553
|
dbiRoleSelectMenu.name,
|
|
548
554
|
dbiRoleSelectMenu as any
|
|
549
555
|
);
|
|
@@ -567,11 +573,13 @@ export class DBI<
|
|
|
567
573
|
self.data.interactions.has(dbiChannelSelectMenu.name)
|
|
568
574
|
)
|
|
569
575
|
throw new Error(
|
|
570
|
-
`DBIChannelSelectMenu "${
|
|
571
|
-
|
|
576
|
+
`DBIChannelSelectMenu "${
|
|
577
|
+
dbiChannelSelectMenu.name
|
|
578
|
+
}" already loaded as "${
|
|
579
|
+
self.data.interactions.get(dbiChannelSelectMenu.name)?.type
|
|
572
580
|
}"!`
|
|
573
581
|
);
|
|
574
|
-
self.data.interactions.set(
|
|
582
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
575
583
|
dbiChannelSelectMenu.name,
|
|
576
584
|
dbiChannelSelectMenu as any
|
|
577
585
|
);
|
|
@@ -598,11 +606,13 @@ export class DBI<
|
|
|
598
606
|
self.data.interactions.has(dbiMentionableSelectMenu.name)
|
|
599
607
|
)
|
|
600
608
|
throw new Error(
|
|
601
|
-
`DBIMentionableSelectMenu "${
|
|
602
|
-
|
|
609
|
+
`DBIMentionableSelectMenu "${
|
|
610
|
+
dbiMentionableSelectMenu.name
|
|
611
|
+
}" already loaded as "${
|
|
612
|
+
self.data.interactions.get(dbiMentionableSelectMenu.name)?.type
|
|
603
613
|
}"!`
|
|
604
614
|
);
|
|
605
|
-
self.data.interactions.set(
|
|
615
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
606
616
|
dbiMentionableSelectMenu.name,
|
|
607
617
|
dbiMentionableSelectMenu as any
|
|
608
618
|
);
|
|
@@ -626,11 +636,13 @@ export class DBI<
|
|
|
626
636
|
self.data.interactions.has(dbiMessageContextMenu.name)
|
|
627
637
|
)
|
|
628
638
|
throw new Error(
|
|
629
|
-
`DBIMessageContextMenu "${
|
|
630
|
-
|
|
639
|
+
`DBIMessageContextMenu "${
|
|
640
|
+
dbiMessageContextMenu.name
|
|
641
|
+
}" already loaded as "${
|
|
642
|
+
self.data.interactions.get(dbiMessageContextMenu.name)?.type
|
|
631
643
|
}"!`
|
|
632
644
|
);
|
|
633
|
-
self.data.interactions.set(
|
|
645
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
634
646
|
dbiMessageContextMenu.name,
|
|
635
647
|
dbiMessageContextMenu as any
|
|
636
648
|
);
|
|
@@ -654,11 +666,13 @@ export class DBI<
|
|
|
654
666
|
self.data.interactions.has(dbiUserContextMenu.name)
|
|
655
667
|
)
|
|
656
668
|
throw new Error(
|
|
657
|
-
`DBIUserContextMenu "${
|
|
658
|
-
|
|
669
|
+
`DBIUserContextMenu "${
|
|
670
|
+
dbiUserContextMenu.name
|
|
671
|
+
}" already loaded as "${
|
|
672
|
+
self.data.interactions.get(dbiUserContextMenu.name)?.type
|
|
659
673
|
}"!`
|
|
660
674
|
);
|
|
661
|
-
self.data.interactions.set(
|
|
675
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(
|
|
662
676
|
dbiUserContextMenu.name,
|
|
663
677
|
dbiUserContextMenu as any
|
|
664
678
|
);
|
|
@@ -677,10 +691,11 @@ export class DBI<
|
|
|
677
691
|
let dbiModal = new DBIModal(self as any, cfg);
|
|
678
692
|
if (self.config.strict && self.data.interactions.has(dbiModal.name))
|
|
679
693
|
throw new Error(
|
|
680
|
-
`DBIModal "${dbiModal.name}" already loaded as "${
|
|
694
|
+
`DBIModal "${dbiModal.name}" already loaded as "${
|
|
695
|
+
self.data.interactions.get(dbiModal.name)?.type
|
|
681
696
|
}"!`
|
|
682
697
|
);
|
|
683
|
-
self.data.interactions.set(dbiModal.name, dbiModal as any);
|
|
698
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactions.set(dbiModal.name, dbiModal as any);
|
|
684
699
|
return dbiModal;
|
|
685
700
|
};
|
|
686
701
|
Modal = Object.assign(
|
|
@@ -701,7 +716,7 @@ export class DBI<
|
|
|
701
716
|
throw new Error(`DBILocale "${dbiLocale.name}" already loaded!`);
|
|
702
717
|
if (self.data.locales.has(dbiLocale.name))
|
|
703
718
|
dbiLocale.mergeLocale(self.data.locales.get(dbiLocale.name));
|
|
704
|
-
self.data.locales.set(dbiLocale.name, dbiLocale);
|
|
719
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.locales.set(dbiLocale.name, dbiLocale);
|
|
705
720
|
return dbiLocale;
|
|
706
721
|
};
|
|
707
722
|
Locale = Object.assign(
|
|
@@ -741,7 +756,7 @@ export class DBI<
|
|
|
741
756
|
throw new Error(
|
|
742
757
|
`DBIInteractionLocale "${dbiInteractionLocale.name}" already loaded!`
|
|
743
758
|
);
|
|
744
|
-
self.data.interactionLocales.set(
|
|
759
|
+
if (!cfg.flag || flags.includes("all") || flags.includes(cfg.flag)) self.data.interactionLocales.set(
|
|
745
760
|
dbiInteractionLocale.name,
|
|
746
761
|
dbiInteractionLocale
|
|
747
762
|
);
|
|
@@ -873,9 +888,9 @@ export class DBI<
|
|
|
873
888
|
this.data.registers.add(cb);
|
|
874
889
|
}
|
|
875
890
|
|
|
876
|
-
async load(): Promise<boolean> {
|
|
891
|
+
async load(...flags: string[]): Promise<boolean> {
|
|
877
892
|
if (this._loaded) return false;
|
|
878
|
-
await this._registerAll();
|
|
893
|
+
await this._registerAll(flags);
|
|
879
894
|
await this._hookListeners();
|
|
880
895
|
this._loaded = true;
|
|
881
896
|
return true;
|
|
@@ -899,13 +914,9 @@ export class DBI<
|
|
|
899
914
|
async publish(...args: any[]) {
|
|
900
915
|
let interactions = this.data.interactions.filter(
|
|
901
916
|
(i) =>
|
|
902
|
-
i.
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
i.type == "ChatInput" ||
|
|
906
|
-
i.type == "MessageContextMenu" ||
|
|
907
|
-
i.type == "UserContextMenu"
|
|
908
|
-
)
|
|
917
|
+
i.type == "ChatInput" ||
|
|
918
|
+
i.type == "MessageContextMenu" ||
|
|
919
|
+
i.type == "UserContextMenu"
|
|
909
920
|
) as any;
|
|
910
921
|
switch (args[0]) {
|
|
911
922
|
case "Global": {
|
|
@@ -24,14 +24,14 @@ export async function publishInteractions(
|
|
|
24
24
|
|
|
25
25
|
let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =
|
|
26
26
|
interactions.reduce((all, current) => {
|
|
27
|
-
if (current.publish && !all[current.publish
|
|
27
|
+
if (current.publish && !all[current.publish]) all[current.publish] = [];
|
|
28
28
|
switch (current.type) {
|
|
29
29
|
case "ChatInput": {
|
|
30
30
|
let nameSplitted = current.name.split(" ");
|
|
31
31
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
32
32
|
switch (nameSplitted.length) {
|
|
33
33
|
case 1: {
|
|
34
|
-
all[current.publish
|
|
34
|
+
all[current.publish].push({
|
|
35
35
|
type: ApplicationCommandType.ChatInput,
|
|
36
36
|
description: current.description,
|
|
37
37
|
name: nameSplitted[0],
|
|
@@ -44,7 +44,7 @@ export async function publishInteractions(
|
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
case 2: {
|
|
47
|
-
let baseItem = all[current.publish
|
|
47
|
+
let baseItem = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
48
48
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
49
49
|
let option = {
|
|
50
50
|
type: ApplicationCommandOptionType.Subcommand,
|
|
@@ -56,7 +56,7 @@ export async function publishInteractions(
|
|
|
56
56
|
description_localizations: localeData.descriptionLocales,
|
|
57
57
|
};
|
|
58
58
|
if (!baseItem) {
|
|
59
|
-
all[current.publish
|
|
59
|
+
all[current.publish].push({
|
|
60
60
|
type: ApplicationCommandType.ChatInput,
|
|
61
61
|
name: nameSplitted[0],
|
|
62
62
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
@@ -72,10 +72,10 @@ export async function publishInteractions(
|
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case 3: {
|
|
75
|
-
let level1Item = all[current.publish
|
|
75
|
+
let level1Item = all[current.publish].find(i => i.name == current.name.split(" ")[0] && i.type == ApplicationCommandType.ChatInput);
|
|
76
76
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
77
77
|
if (!level1Item) {
|
|
78
|
-
all[current.publish
|
|
78
|
+
all[current.publish].push({
|
|
79
79
|
type: ApplicationCommandType.ChatInput,
|
|
80
80
|
name: nameSplitted[0],
|
|
81
81
|
name_localizations: localeData.nameLocales(0),
|
|
@@ -140,7 +140,7 @@ export async function publishInteractions(
|
|
|
140
140
|
}
|
|
141
141
|
case "MessageContextMenu": {
|
|
142
142
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
143
|
-
all[current.publish
|
|
143
|
+
all[current.publish].push({
|
|
144
144
|
type: ApplicationCommandType.Message,
|
|
145
145
|
name: current.name,
|
|
146
146
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
|
@@ -152,7 +152,7 @@ export async function publishInteractions(
|
|
|
152
152
|
}
|
|
153
153
|
case "UserContextMenu": {
|
|
154
154
|
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);
|
|
155
|
-
all[current.publish
|
|
155
|
+
all[current.publish].push({
|
|
156
156
|
type: ApplicationCommandType.User,
|
|
157
157
|
name: current.name,
|
|
158
158
|
default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),
|
package/src/types/Event.ts
CHANGED
|
@@ -112,6 +112,7 @@ export class DBIEvent<TNamespace extends NamespaceEnums> {
|
|
|
112
112
|
ordered?: boolean;
|
|
113
113
|
dbi: DBI<TNamespace>;
|
|
114
114
|
disabled: boolean = false;
|
|
115
|
+
flag: string | undefined;
|
|
115
116
|
constructor(dbi: DBI<TNamespace>, cfg: TDBIEventOmitted<TNamespace>) {
|
|
116
117
|
this.dbi = dbi;
|
|
117
118
|
this.type = "Event";
|
|
@@ -122,6 +123,7 @@ export class DBIEvent<TNamespace extends NamespaceEnums> {
|
|
|
122
123
|
this.ordered = cfg.ordered ?? false;
|
|
123
124
|
this.triggerType = cfg.triggerType ?? "OneByOneGlobal";
|
|
124
125
|
this.disabled ??= cfg.disabled;
|
|
126
|
+
this.flag = cfg.flag;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
toggle(disabled?: boolean) {
|
package/src/types/Interaction.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type TDBIRateLimitTypes =
|
|
|
54
54
|
| "Message";
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
export type
|
|
57
|
+
export type DBIRateLimit = {
|
|
58
58
|
type: TDBIRateLimitTypes;
|
|
59
59
|
/**
|
|
60
60
|
* Duration in milliseconds.
|
|
@@ -62,18 +62,6 @@ export type TDBIRateLimit = {
|
|
|
62
62
|
duration: number;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export type TDBIPublishTypes =
|
|
66
|
-
| "Guild"
|
|
67
|
-
| "Global"
|
|
68
|
-
| "None"
|
|
69
|
-
| "All";
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export type TDBIPublish = {
|
|
73
|
-
type: TDBIPublishTypes;
|
|
74
|
-
to: NamespaceData[NamespaceEnums]["clientNamespaces"];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
65
|
export class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
78
66
|
constructor(dbi: DBI<TNamespace>, cfg: Omit<DBIBaseInteraction<TNamespace>, "dbi">) {
|
|
79
67
|
this.dbi = dbi;
|
|
@@ -83,23 +71,20 @@ export class DBIBaseInteraction<TNamespace extends NamespaceEnums> {
|
|
|
83
71
|
this.type = cfg.type;
|
|
84
72
|
this.options = cfg.options;
|
|
85
73
|
this.other = cfg.other;
|
|
86
|
-
this.publish = cfg.publish ??
|
|
87
|
-
to: dbi.data.clients.first()?.namespace,
|
|
88
|
-
type: "All"
|
|
89
|
-
};
|
|
90
|
-
if (!this.publish.to) this.publish.to = dbi.data.clients.first()?.namespace;
|
|
91
|
-
if (!this.publish.type) this.publish.type = "All";
|
|
74
|
+
this.publish = cfg.publish ?? dbi.data.clients.first()?.namespace;
|
|
92
75
|
this.rateLimits = cfg.rateLimits ?? [];
|
|
76
|
+
this.flag = cfg.flag;
|
|
93
77
|
}
|
|
94
78
|
|
|
95
|
-
publish?:
|
|
79
|
+
publish?: NamespaceData[TNamespace]["clientNamespaces"];
|
|
96
80
|
dbi: DBI<TNamespace>;
|
|
97
81
|
name: string;
|
|
98
82
|
description: string;
|
|
99
83
|
readonly type: TDBIInteractionTypes;
|
|
100
84
|
options?: any | any[];
|
|
101
85
|
other?: Record<string, any> & { messageCommand?: { aliases?: string[] } };
|
|
102
|
-
rateLimits?:
|
|
86
|
+
rateLimits?: DBIRateLimit[];
|
|
87
|
+
flag: string | undefined;
|
|
103
88
|
toJSON(overrides: any): any { }
|
|
104
89
|
|
|
105
90
|
onExecute(ctx: IDBIBaseExecuteCtx<TNamespace>): Promise<void> | void {
|
|
@@ -131,7 +131,7 @@ export class FakeMessageInteraction /* implements ChatInputCommandInteraction */
|
|
|
131
131
|
};
|
|
132
132
|
},
|
|
133
133
|
get _hoistedOptions() {
|
|
134
|
-
return
|
|
134
|
+
return self._hoistedOptions;
|
|
135
135
|
},
|
|
136
136
|
getSubcommand() {
|
|
137
137
|
let splitted = self.fullCommandName.split(" ");
|
|
@@ -24,9 +24,11 @@ export class DBIInteractionLocale {
|
|
|
24
24
|
name: string;
|
|
25
25
|
data: TDBIInteractionLocaleData;
|
|
26
26
|
dbi: DBI<NamespaceEnums>;
|
|
27
|
+
flag: string | undefined;
|
|
27
28
|
constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {
|
|
28
29
|
this.dbi = dbi;
|
|
29
30
|
this.name = cfg.name;
|
|
30
31
|
this.data = cfg.data;
|
|
32
|
+
this.flag = cfg.flag;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -20,9 +20,11 @@ export class DBILocale<TNamespace extends NamespaceEnums> {
|
|
|
20
20
|
data: NamespaceData[TNamespace]["contentLocale"];
|
|
21
21
|
private _data: DBILangConstructorObject;
|
|
22
22
|
dbi: DBI<TNamespace, {}>;
|
|
23
|
+
flag: string | undefined
|
|
23
24
|
constructor(dbi: DBI<TNamespace, {}>, cfg: TDBILocaleConstructor<TNamespace>) {
|
|
24
25
|
this.dbi = dbi;
|
|
25
26
|
this.name = cfg.name;
|
|
27
|
+
this.flag = cfg.flag;
|
|
26
28
|
this._data = cfg.data;
|
|
27
29
|
this.data = convertLang<TNamespace>(cfg.data);
|
|
28
30
|
}
|