@mostfeatured/dbi 0.0.63 → 0.0.64
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 +164 -164
- package/dist/DBI.js +332 -332
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/methods/publishInteractions.js +236 -236
- package/dist/types/Button.js +1 -1
- package/dist/types/Button.js.map +1 -1
- package/dist/types/Modal.js +1 -1
- package/dist/types/Modal.js.map +1 -1
- package/dist/types/SelectMenu.js +1 -1
- package/dist/types/SelectMenu.js.map +1 -1
- package/dist/utils/customId.d.ts +1 -1
- package/dist/utils/customId.d.ts.map +1 -1
- package/dist/utils/customId.js +8 -4
- package/dist/utils/customId.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +8 -1
- package/src/types/Button.ts +2 -2
- package/src/types/Modal.ts +2 -2
- package/src/types/SelectMenu.ts +2 -2
- package/src/utils/customId.ts +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { NamespaceEnums } from "../generated/namespaceData";
|
|
|
2
2
|
import { DBI, DBIConfigConstructor } from "./DBI";
|
|
3
3
|
export { recursiveImport } from "./utils/recursiveImport";
|
|
4
4
|
export { MemoryStore } from "./utils/MemoryStore";
|
|
5
|
+
import { parseCustomId, buildCustomId } from "./utils/customId";
|
|
5
6
|
export declare const generatedPath: string;
|
|
6
7
|
export declare function createDBI<TNamespace extends NamespaceEnums, TOtherType = Record<string, any>>(namespace: TNamespace, cfg: DBIConfigConstructor): DBI<TNamespace, TOtherType>;
|
|
8
|
+
export declare const Utils: {
|
|
9
|
+
parseCustomId: typeof parseCustomId;
|
|
10
|
+
buildCustomId: typeof buildCustomId;
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,eAAO,MAAM,aAAa,QAA0C,CAAC;AAErE,wBAAgB,SAAS,CAAC,UAAU,SAAS,cAAc,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAE5K"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEhE,eAAO,MAAM,aAAa,QAA0C,CAAC;AAErE,wBAAgB,SAAS,CAAC,UAAU,SAAS,cAAc,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,GAAG,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAE5K;AAED,eAAO,MAAM,KAAK;;;CAGjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDBI = exports.generatedPath = exports.MemoryStore = exports.recursiveImport = void 0;
|
|
3
|
+
exports.Utils = exports.createDBI = exports.generatedPath = exports.MemoryStore = exports.recursiveImport = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const DBI_1 = require("./DBI");
|
|
6
6
|
var recursiveImport_1 = require("./utils/recursiveImport");
|
|
@@ -8,10 +8,15 @@ Object.defineProperty(exports, "recursiveImport", { enumerable: true, get: funct
|
|
|
8
8
|
var MemoryStore_1 = require("./utils/MemoryStore");
|
|
9
9
|
Object.defineProperty(exports, "MemoryStore", { enumerable: true, get: function () { return MemoryStore_1.MemoryStore; } });
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const customId_1 = require("./utils/customId");
|
|
11
12
|
exports.generatedPath = path_1.default.resolve(__dirname, "../generated");
|
|
12
13
|
function createDBI(namespace, cfg) {
|
|
13
14
|
return new DBI_1.DBI(namespace, cfg);
|
|
14
15
|
}
|
|
15
16
|
exports.createDBI = createDBI;
|
|
16
17
|
;
|
|
18
|
+
exports.Utils = {
|
|
19
|
+
parseCustomId: customId_1.parseCustomId,
|
|
20
|
+
buildCustomId: customId_1.buildCustomId
|
|
21
|
+
};
|
|
17
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,+BAAkD;AAClD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,wDAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,+BAAkD;AAClD,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB,wDAAwB;AACxB,+CAAgE;AAEnD,QAAA,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAErE,SAAgB,SAAS,CAAsE,SAAqB,EAAE,GAAyB;IAC7I,OAAO,IAAI,SAAG,CAAyB,SAAS,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AAFD,8BAEC;AAAA,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,aAAa,EAAb,wBAAa;IACb,aAAa,EAAb,wBAAa;CACd,CAAA","sourcesContent":["import { NamespaceEnums } from \"../generated/namespaceData\";\r\nimport { DBI, DBIConfigConstructor } from \"./DBI\";\r\nexport { recursiveImport } from \"./utils/recursiveImport\";\r\nexport { MemoryStore } from \"./utils/MemoryStore\";\r\n\r\nimport path from \"path\";\r\nimport { parseCustomId, buildCustomId } from \"./utils/customId\";\r\n\r\nexport const generatedPath = path.resolve(__dirname, \"../generated\");\r\n\r\nexport function createDBI<TNamespace extends NamespaceEnums, TOtherType = Record<string, any>>(namespace: TNamespace, cfg: DBIConfigConstructor): DBI<TNamespace, TOtherType> {\r\n return new DBI<TNamespace, TOtherType>(namespace, cfg);\r\n};\r\n\r\nexport const Utils = {\r\n parseCustomId,\r\n buildCustomId\r\n}"]}
|
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatLocale = exports.localeifyOptions = exports.publishInteractions = void 0;
|
|
4
|
-
const rest_1 = require("@discordjs/rest");
|
|
5
|
-
const v9_1 = require("discord-api-types/v9");
|
|
6
|
-
const permissions_1 = require("../utils/permissions");
|
|
7
|
-
const PUBLISHABLE_TYPES = ["ChatInput", "UserContextMenu", "MessageContextMenu"];
|
|
8
|
-
const ORIGINAL_LOCALES = ["da", "de", "en-GB", "en-US", "es-ES", "fr", "hr", "it", "lt", "hu", "nl", "no", "pl", "pt-BR", "ro", "fi", "sv-SE", "vi", "tr", "cs", "el", "bg", "ru", "uk", "hi", "th", "zh-CN", "ja", "zh-TW", "ko"];
|
|
9
|
-
async function publishInteractions(clientToken, interactions, interactionsLocales, publishType, guildId) {
|
|
10
|
-
interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));
|
|
11
|
-
const rest = new rest_1.REST({ version: "10" });
|
|
12
|
-
rest.setToken(clientToken);
|
|
13
|
-
const me = await rest.get(v9_1.Routes.user());
|
|
14
|
-
interactions = interactions.sort((a, b) => b.name.split(" ").length - a.name.split(" ").length);
|
|
15
|
-
let body = interactions.reduce((all, current) => {
|
|
16
|
-
switch (current.type) {
|
|
17
|
-
case "ChatInput": {
|
|
18
|
-
let nameSplitted = current.name.split(" ");
|
|
19
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
20
|
-
switch (nameSplitted.length) {
|
|
21
|
-
case 1: {
|
|
22
|
-
all.push({
|
|
23
|
-
type: v9_1.ApplicationCommandType.ChatInput,
|
|
24
|
-
description: current.description,
|
|
25
|
-
name: nameSplitted[0],
|
|
26
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
27
|
-
dm_permission: current.directMessages,
|
|
28
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
29
|
-
name_localizations: localeData.nameLocales(0),
|
|
30
|
-
description_localizations: localeData.descriptionLocales,
|
|
31
|
-
});
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 2: {
|
|
35
|
-
let baseItem = all.find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
36
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
37
|
-
let option = {
|
|
38
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
39
|
-
name: nameSplitted[1],
|
|
40
|
-
description: current.description,
|
|
41
|
-
dm_permission: current.directMessages,
|
|
42
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
43
|
-
name_localizations: localeData.nameLocales(1),
|
|
44
|
-
description_localizations: localeData.descriptionLocales,
|
|
45
|
-
};
|
|
46
|
-
if (!baseItem) {
|
|
47
|
-
all.push({
|
|
48
|
-
type: v9_1.ApplicationCommandType.ChatInput,
|
|
49
|
-
name: nameSplitted[0],
|
|
50
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
51
|
-
name_localizations: localeData.nameLocales(0),
|
|
52
|
-
description: "...",
|
|
53
|
-
options: [
|
|
54
|
-
option
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
baseItem.options.push(option);
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case 3: {
|
|
64
|
-
let level1Item = all.find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
65
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
66
|
-
if (!level1Item) {
|
|
67
|
-
all.push({
|
|
68
|
-
type: v9_1.ApplicationCommandType.ChatInput,
|
|
69
|
-
name: nameSplitted[0],
|
|
70
|
-
name_localizations: localeData.nameLocales(0),
|
|
71
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
72
|
-
description: "...",
|
|
73
|
-
options: [
|
|
74
|
-
{
|
|
75
|
-
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
76
|
-
name: nameSplitted[1],
|
|
77
|
-
name_localizations: localeData.nameLocales(1),
|
|
78
|
-
description: "...",
|
|
79
|
-
options: [
|
|
80
|
-
{
|
|
81
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
82
|
-
name: nameSplitted[2],
|
|
83
|
-
description: current.description,
|
|
84
|
-
dm_permission: current.directMessages,
|
|
85
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
86
|
-
name_localizations: localeData.nameLocales(2),
|
|
87
|
-
description_localizations: localeData.descriptionLocales,
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
let level2Item = level1Item.options.find(i => i.name == current.name.split(" ")[1]);
|
|
96
|
-
if (!level2Item) {
|
|
97
|
-
level1Item.options.push({
|
|
98
|
-
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
99
|
-
name: nameSplitted[1],
|
|
100
|
-
name_localizations: localeData.nameLocales(1),
|
|
101
|
-
description: "...",
|
|
102
|
-
options: [
|
|
103
|
-
{
|
|
104
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
105
|
-
name: nameSplitted[2],
|
|
106
|
-
description: current.description,
|
|
107
|
-
dm_permission: current.directMessages,
|
|
108
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
109
|
-
name_localizations: localeData.nameLocales(2),
|
|
110
|
-
description_localizations: localeData.descriptionLocales
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
level2Item.options.push({
|
|
117
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
118
|
-
name: nameSplitted[2],
|
|
119
|
-
description: current.description,
|
|
120
|
-
dm_permission: current.directMessages,
|
|
121
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
122
|
-
name_localizations: localeData.nameLocales(2),
|
|
123
|
-
description_localizations: localeData.descriptionLocales,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case "MessageContextMenu": {
|
|
133
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
134
|
-
all.push({
|
|
135
|
-
type: v9_1.ApplicationCommandType.Message,
|
|
136
|
-
name: current.name,
|
|
137
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
138
|
-
dm_permission: current.directMessages,
|
|
139
|
-
name_localizations: localeData.allNameLocales,
|
|
140
|
-
description_localizations: localeData.descriptionLocales,
|
|
141
|
-
});
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
case "UserContextMenu": {
|
|
145
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
146
|
-
all.push({
|
|
147
|
-
type: v9_1.ApplicationCommandType.User,
|
|
148
|
-
name: current.name,
|
|
149
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
150
|
-
dm_permission: current.directMessages,
|
|
151
|
-
name_localizations: localeData.allNameLocales,
|
|
152
|
-
description_localizations: localeData.descriptionLocales
|
|
153
|
-
});
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return all;
|
|
158
|
-
}, []);
|
|
159
|
-
switch (publishType) {
|
|
160
|
-
case "Guild": {
|
|
161
|
-
await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case "Global": {
|
|
165
|
-
await rest.put(v9_1.Routes.applicationCommands(me.id), { body });
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.publishInteractions = publishInteractions;
|
|
171
|
-
function localeifyOptions(options, localeData) {
|
|
172
|
-
return options.map(i => {
|
|
173
|
-
let optionData = localeData[i.name];
|
|
174
|
-
return optionData ? Object.assign(i, {
|
|
175
|
-
name_localizations: optionData.nameLocales,
|
|
176
|
-
description_localizations: optionData.descriptionLocales,
|
|
177
|
-
choices: i.choices ? i.choices.map((j) => {
|
|
178
|
-
let choiceLocale = optionData.choiceLocales[j.name];
|
|
179
|
-
return choiceLocale ? Object.assign(j, {
|
|
180
|
-
name_localizations: choiceLocale
|
|
181
|
-
}) : j;
|
|
182
|
-
}) : undefined
|
|
183
|
-
}) : i;
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
exports.localeifyOptions = localeifyOptions;
|
|
187
|
-
function formatLocale(locale) {
|
|
188
|
-
let allNameLocales = {};
|
|
189
|
-
let descriptionLocales = {};
|
|
190
|
-
let optionsLocales = {};
|
|
191
|
-
function nameLocales(index) {
|
|
192
|
-
return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], i[1].split(" ").at(index)]));
|
|
193
|
-
}
|
|
194
|
-
if (!locale?.data)
|
|
195
|
-
return {
|
|
196
|
-
nameLocales,
|
|
197
|
-
allNameLocales,
|
|
198
|
-
descriptionLocales,
|
|
199
|
-
optionsLocales
|
|
200
|
-
};
|
|
201
|
-
Object.entries(locale.data).forEach(([shortLocale, localeData]) => {
|
|
202
|
-
let longAliases = ORIGINAL_LOCALES.filter(i => i.split("-").at(0) == shortLocale);
|
|
203
|
-
longAliases.forEach((longLocale) => {
|
|
204
|
-
allNameLocales[longLocale] = localeData.name;
|
|
205
|
-
descriptionLocales[longLocale] = localeData.description;
|
|
206
|
-
Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
|
|
207
|
-
if (!optionsLocales[optionName])
|
|
208
|
-
optionsLocales[optionName] = {};
|
|
209
|
-
let optionLocale = optionsLocales[optionName];
|
|
210
|
-
if (!optionLocale.nameLocales)
|
|
211
|
-
optionLocale.nameLocales = {};
|
|
212
|
-
if (!optionLocale.descriptionLocales)
|
|
213
|
-
optionLocale.descriptionLocales = {};
|
|
214
|
-
if (!optionLocale.choiceLocales)
|
|
215
|
-
optionLocale.choiceLocales = {};
|
|
216
|
-
Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
|
|
217
|
-
if (!optionLocale.choiceLocales)
|
|
218
|
-
optionLocale.choiceLocales = {};
|
|
219
|
-
if (!optionLocale.choiceLocales[choiceOriginalName])
|
|
220
|
-
optionLocale.choiceLocales[choiceOriginalName] = {};
|
|
221
|
-
let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
|
|
222
|
-
choiceLocale[longLocale] = choiceName;
|
|
223
|
-
});
|
|
224
|
-
optionLocale.nameLocales[longLocale] = optionData.name;
|
|
225
|
-
optionLocale.descriptionLocales[longLocale] = optionData.description;
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
return {
|
|
230
|
-
nameLocales,
|
|
231
|
-
allNameLocales,
|
|
232
|
-
descriptionLocales,
|
|
233
|
-
optionsLocales
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
exports.formatLocale = formatLocale;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatLocale = exports.localeifyOptions = exports.publishInteractions = void 0;
|
|
4
|
+
const rest_1 = require("@discordjs/rest");
|
|
5
|
+
const v9_1 = require("discord-api-types/v9");
|
|
6
|
+
const permissions_1 = require("../utils/permissions");
|
|
7
|
+
const PUBLISHABLE_TYPES = ["ChatInput", "UserContextMenu", "MessageContextMenu"];
|
|
8
|
+
const ORIGINAL_LOCALES = ["da", "de", "en-GB", "en-US", "es-ES", "fr", "hr", "it", "lt", "hu", "nl", "no", "pl", "pt-BR", "ro", "fi", "sv-SE", "vi", "tr", "cs", "el", "bg", "ru", "uk", "hi", "th", "zh-CN", "ja", "zh-TW", "ko"];
|
|
9
|
+
async function publishInteractions(clientToken, interactions, interactionsLocales, publishType, guildId) {
|
|
10
|
+
interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));
|
|
11
|
+
const rest = new rest_1.REST({ version: "10" });
|
|
12
|
+
rest.setToken(clientToken);
|
|
13
|
+
const me = await rest.get(v9_1.Routes.user());
|
|
14
|
+
interactions = interactions.sort((a, b) => b.name.split(" ").length - a.name.split(" ").length);
|
|
15
|
+
let body = interactions.reduce((all, current) => {
|
|
16
|
+
switch (current.type) {
|
|
17
|
+
case "ChatInput": {
|
|
18
|
+
let nameSplitted = current.name.split(" ");
|
|
19
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
20
|
+
switch (nameSplitted.length) {
|
|
21
|
+
case 1: {
|
|
22
|
+
all.push({
|
|
23
|
+
type: v9_1.ApplicationCommandType.ChatInput,
|
|
24
|
+
description: current.description,
|
|
25
|
+
name: nameSplitted[0],
|
|
26
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
27
|
+
dm_permission: current.directMessages,
|
|
28
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
29
|
+
name_localizations: localeData.nameLocales(0),
|
|
30
|
+
description_localizations: localeData.descriptionLocales,
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case 2: {
|
|
35
|
+
let baseItem = all.find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
36
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
37
|
+
let option = {
|
|
38
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
39
|
+
name: nameSplitted[1],
|
|
40
|
+
description: current.description,
|
|
41
|
+
dm_permission: current.directMessages,
|
|
42
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
43
|
+
name_localizations: localeData.nameLocales(1),
|
|
44
|
+
description_localizations: localeData.descriptionLocales,
|
|
45
|
+
};
|
|
46
|
+
if (!baseItem) {
|
|
47
|
+
all.push({
|
|
48
|
+
type: v9_1.ApplicationCommandType.ChatInput,
|
|
49
|
+
name: nameSplitted[0],
|
|
50
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
51
|
+
name_localizations: localeData.nameLocales(0),
|
|
52
|
+
description: "...",
|
|
53
|
+
options: [
|
|
54
|
+
option
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
baseItem.options.push(option);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case 3: {
|
|
64
|
+
let level1Item = all.find(i => i.name == current.name.split(" ")[0] && i.type == v9_1.ApplicationCommandType.ChatInput);
|
|
65
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
66
|
+
if (!level1Item) {
|
|
67
|
+
all.push({
|
|
68
|
+
type: v9_1.ApplicationCommandType.ChatInput,
|
|
69
|
+
name: nameSplitted[0],
|
|
70
|
+
name_localizations: localeData.nameLocales(0),
|
|
71
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
72
|
+
description: "...",
|
|
73
|
+
options: [
|
|
74
|
+
{
|
|
75
|
+
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
76
|
+
name: nameSplitted[1],
|
|
77
|
+
name_localizations: localeData.nameLocales(1),
|
|
78
|
+
description: "...",
|
|
79
|
+
options: [
|
|
80
|
+
{
|
|
81
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
82
|
+
name: nameSplitted[2],
|
|
83
|
+
description: current.description,
|
|
84
|
+
dm_permission: current.directMessages,
|
|
85
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
86
|
+
name_localizations: localeData.nameLocales(2),
|
|
87
|
+
description_localizations: localeData.descriptionLocales,
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
let level2Item = level1Item.options.find(i => i.name == current.name.split(" ")[1]);
|
|
96
|
+
if (!level2Item) {
|
|
97
|
+
level1Item.options.push({
|
|
98
|
+
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
99
|
+
name: nameSplitted[1],
|
|
100
|
+
name_localizations: localeData.nameLocales(1),
|
|
101
|
+
description: "...",
|
|
102
|
+
options: [
|
|
103
|
+
{
|
|
104
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
105
|
+
name: nameSplitted[2],
|
|
106
|
+
description: current.description,
|
|
107
|
+
dm_permission: current.directMessages,
|
|
108
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
109
|
+
name_localizations: localeData.nameLocales(2),
|
|
110
|
+
description_localizations: localeData.descriptionLocales
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
level2Item.options.push({
|
|
117
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
118
|
+
name: nameSplitted[2],
|
|
119
|
+
description: current.description,
|
|
120
|
+
dm_permission: current.directMessages,
|
|
121
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
122
|
+
name_localizations: localeData.nameLocales(2),
|
|
123
|
+
description_localizations: localeData.descriptionLocales,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "MessageContextMenu": {
|
|
133
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
134
|
+
all.push({
|
|
135
|
+
type: v9_1.ApplicationCommandType.Message,
|
|
136
|
+
name: current.name,
|
|
137
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
138
|
+
dm_permission: current.directMessages,
|
|
139
|
+
name_localizations: localeData.allNameLocales,
|
|
140
|
+
description_localizations: localeData.descriptionLocales,
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case "UserContextMenu": {
|
|
145
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
146
|
+
all.push({
|
|
147
|
+
type: v9_1.ApplicationCommandType.User,
|
|
148
|
+
name: current.name,
|
|
149
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
150
|
+
dm_permission: current.directMessages,
|
|
151
|
+
name_localizations: localeData.allNameLocales,
|
|
152
|
+
description_localizations: localeData.descriptionLocales
|
|
153
|
+
});
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return all;
|
|
158
|
+
}, []);
|
|
159
|
+
switch (publishType) {
|
|
160
|
+
case "Guild": {
|
|
161
|
+
await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "Global": {
|
|
165
|
+
await rest.put(v9_1.Routes.applicationCommands(me.id), { body });
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.publishInteractions = publishInteractions;
|
|
171
|
+
function localeifyOptions(options, localeData) {
|
|
172
|
+
return options.map(i => {
|
|
173
|
+
let optionData = localeData[i.name];
|
|
174
|
+
return optionData ? Object.assign(i, {
|
|
175
|
+
name_localizations: optionData.nameLocales,
|
|
176
|
+
description_localizations: optionData.descriptionLocales,
|
|
177
|
+
choices: i.choices ? i.choices.map((j) => {
|
|
178
|
+
let choiceLocale = optionData.choiceLocales[j.name];
|
|
179
|
+
return choiceLocale ? Object.assign(j, {
|
|
180
|
+
name_localizations: choiceLocale
|
|
181
|
+
}) : j;
|
|
182
|
+
}) : undefined
|
|
183
|
+
}) : i;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
exports.localeifyOptions = localeifyOptions;
|
|
187
|
+
function formatLocale(locale) {
|
|
188
|
+
let allNameLocales = {};
|
|
189
|
+
let descriptionLocales = {};
|
|
190
|
+
let optionsLocales = {};
|
|
191
|
+
function nameLocales(index) {
|
|
192
|
+
return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], i[1].split(" ").at(index)]));
|
|
193
|
+
}
|
|
194
|
+
if (!locale?.data)
|
|
195
|
+
return {
|
|
196
|
+
nameLocales,
|
|
197
|
+
allNameLocales,
|
|
198
|
+
descriptionLocales,
|
|
199
|
+
optionsLocales
|
|
200
|
+
};
|
|
201
|
+
Object.entries(locale.data).forEach(([shortLocale, localeData]) => {
|
|
202
|
+
let longAliases = ORIGINAL_LOCALES.filter(i => i.split("-").at(0) == shortLocale);
|
|
203
|
+
longAliases.forEach((longLocale) => {
|
|
204
|
+
allNameLocales[longLocale] = localeData.name;
|
|
205
|
+
descriptionLocales[longLocale] = localeData.description;
|
|
206
|
+
Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
|
|
207
|
+
if (!optionsLocales[optionName])
|
|
208
|
+
optionsLocales[optionName] = {};
|
|
209
|
+
let optionLocale = optionsLocales[optionName];
|
|
210
|
+
if (!optionLocale.nameLocales)
|
|
211
|
+
optionLocale.nameLocales = {};
|
|
212
|
+
if (!optionLocale.descriptionLocales)
|
|
213
|
+
optionLocale.descriptionLocales = {};
|
|
214
|
+
if (!optionLocale.choiceLocales)
|
|
215
|
+
optionLocale.choiceLocales = {};
|
|
216
|
+
Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
|
|
217
|
+
if (!optionLocale.choiceLocales)
|
|
218
|
+
optionLocale.choiceLocales = {};
|
|
219
|
+
if (!optionLocale.choiceLocales[choiceOriginalName])
|
|
220
|
+
optionLocale.choiceLocales[choiceOriginalName] = {};
|
|
221
|
+
let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
|
|
222
|
+
choiceLocale[longLocale] = choiceName;
|
|
223
|
+
});
|
|
224
|
+
optionLocale.nameLocales[longLocale] = optionData.name;
|
|
225
|
+
optionLocale.descriptionLocales[longLocale] = optionData.description;
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
nameLocales,
|
|
231
|
+
allNameLocales,
|
|
232
|
+
descriptionLocales,
|
|
233
|
+
optionsLocales
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
exports.formatLocale = formatLocale;
|
|
237
237
|
//# sourceMappingURL=publishInteractions.js.map
|
package/dist/types/Button.js
CHANGED
|
@@ -19,7 +19,7 @@ class DBIButton extends Interaction_1.DBIBaseInteraction {
|
|
|
19
19
|
toJSON(arg = {}) {
|
|
20
20
|
return {
|
|
21
21
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
22
|
-
customId: (0, customId_1.
|
|
22
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
23
23
|
type: discord_js_1.default.ComponentType.Button,
|
|
24
24
|
};
|
|
25
25
|
}
|
package/dist/types/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAkD;AAGlD,4DAA4B;AAC5B,mDAAuE;AASvE,MAAa,SAA6C,SAAQ,gCAA8B;IAC9F,YAAY,GAAoB,EAAE,IAAmC;QACnE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAqC,IAA0B,CAAC;IAAA,CAAC;IACpF,MAAM,CAAC,MAA0C,EAAE;QACjD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACpG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;IACF,aAAa,CAAC,MAA0C,EAAE;QACxD,OAAO,IAAI,gCAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC1D,CAAC;CAEF;AAtBD,8BAsBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIButtonBuilder, DBIButtonOverrides } from \"./ButtonBuilder\";\r\n\r\nexport interface IDBIButtonExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIButtonOmitted<TNamespace extends NamespaceEnums> = Omit<DBIButton<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIButton<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIButtonOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Button\",\r\n });\r\n }\r\n\r\n declare options?: Omit<Discord.ButtonComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBIButtonExecuteCtx<TNamespace>): Promise<void> | void { };\r\n toJSON(arg: IDBIToJSONArgs<DBIButtonOverrides> = {}): Discord.ButtonComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.Button,\r\n } as any;\r\n };\r\n createBuilder(arg: IDBIToJSONArgs<DBIButtonOverrides> = {}): DBIButtonBuilder<TNamespace> {\r\n return new DBIButtonBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/types/Modal.js
CHANGED
|
@@ -18,7 +18,7 @@ class DBIModal extends Interaction_1.DBIBaseInteraction {
|
|
|
18
18
|
toJSON(arg = {}) {
|
|
19
19
|
return {
|
|
20
20
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
21
|
-
customId: (0, customId_1.
|
|
21
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
;
|
package/dist/types/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;;AACA,+CAA2F;AAE3F,gDAAkD;AAGlD,4DAA4B;AAC5B,iDAAoE;AAgBpE,MAAa,QAA4C,SAAQ,gCAA8B;IAC7F,YAAY,GAAoB,EAAE,IAAkC;QAClE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAoC,IAA0B,CAAC;IAAA,CAAC;IAEnF,MAAM,CAAC,MAAyC,EAAE;QAChD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SAC9F,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAAyC,EAAE;QACvD,OAAO,IAAI,8BAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CAEF;AAvBD,4BAuBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBIModalBuilder, DBIModalOverrides } from \"./ModalBuilder\";\r\n\r\n\r\nexport interface IDBIModalExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted<TNamespace extends NamespaceEnums> = Omit<DBIModal<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBIModalOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n }\r\n\r\n declare options: ModalComponentData;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): DBIModalBuilder<TNamespace> {\r\n return new DBIModalBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/types/SelectMenu.js
CHANGED
|
@@ -19,7 +19,7 @@ class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
|
|
|
19
19
|
toJSON(arg = {}) {
|
|
20
20
|
return {
|
|
21
21
|
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
22
|
-
customId: (0, customId_1.
|
|
22
|
+
customId: (0, customId_1.buildCustomId)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
23
23
|
type: discord_js_1.default.ComponentType.SelectMenu,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAkD;AAGlD,4DAA4B;AAC5B,2DAAmF;AAUnF,MAAa,aAAiD,SAAQ,gCAA8B;IAClG,YAAY,GAAoB,EAAE,IAAuC;QACvE,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyC,IAA0B,CAAC;IAAA,CAAC;IAExF,MAAM,CAAC,MAA8C,EAAE;QACrD,OAAO;YACL,GAAG,gBAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC;YACtE,QAAQ,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACpG,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAC;IACX,CAAC;IAAA,CAAC;IAEF,aAAa,CAAC,MAA8C,EAAE;QAC5D,OAAO,IAAI,wCAAoB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;CAEF;AAxBD,sCAwBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { buildCustomId } from \"../utils/customId\";\r\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport stuffs from \"stuffs\";\r\nimport { DBISelectMenuBuilder, DBISelectMenuOverrides } from \"./SelectMenuBuilder\";\r\n\r\n\r\nexport interface IDBISelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBISelectMenu<TNamespace>, \"type\" | \"description\" | \"dbi\" | \"toJSON\" | \"createBuilder\">;\r\n\r\nexport class DBISelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {\r\n constructor(dbi: DBI<TNamespace>, args: TDBISelectMenuOmitted<TNamespace>) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"SelectMenu\",\r\n });\r\n }\r\n\r\n declare options: Omit<Discord.BaseSelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx<TNamespace>): Promise<void> | void { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): Discord.BaseSelectMenuComponentData {\r\n return {\r\n ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),\r\n customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),\r\n type: Discord.ComponentType.SelectMenu,\r\n } as any;\r\n };\r\n\r\n createBuilder(arg: IDBIToJSONArgs<DBISelectMenuOverrides> = {}): DBISelectMenuBuilder<TNamespace> {\r\n return new DBISelectMenuBuilder({ component: this, ...arg })\r\n }\r\n\r\n}"]}
|
package/dist/utils/customId.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DBI } from "../DBI";
|
|
2
2
|
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?: number): string;
|
|
4
4
|
export declare function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): {
|
|
5
5
|
name: string;
|
|
6
6
|
data: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,
|
|
1
|
+
{"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAC,MAAM,GAAG,MAAM,CAmBtG;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAC,CAarG"}
|