@mostfeatured/dbi 0.0.9 → 0.0.12
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 +40 -16
- package/dist/DBI.d.ts.map +1 -1
- package/dist/DBI.js +61 -17
- package/dist/DBI.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/methods/hookInteractionListeners.d.ts.map +1 -1
- package/dist/methods/hookInteractionListeners.js +8 -4
- package/dist/methods/hookInteractionListeners.js.map +1 -1
- package/dist/methods/publishInteractions.d.ts +4 -1
- package/dist/methods/publishInteractions.d.ts.map +1 -1
- package/dist/methods/publishInteractions.js +83 -10
- package/dist/methods/publishInteractions.js.map +1 -1
- package/dist/types/Button.d.ts +2 -6
- package/dist/types/Button.d.ts.map +1 -1
- package/dist/types/Button.js.map +1 -1
- package/dist/types/Interaction.d.ts +5 -0
- package/dist/types/Interaction.d.ts.map +1 -1
- package/dist/types/Interaction.js.map +1 -1
- package/dist/types/InteractionLocale.d.ts +22 -0
- package/dist/types/InteractionLocale.d.ts.map +1 -0
- package/dist/types/InteractionLocale.js +15 -0
- package/dist/types/InteractionLocale.js.map +1 -0
- package/dist/types/Locale.d.ts +3 -2
- package/dist/types/Locale.d.ts.map +1 -1
- package/dist/types/Locale.js +6 -4
- package/dist/types/Locale.js.map +1 -1
- package/dist/types/Modal.d.ts +2 -6
- package/dist/types/Modal.d.ts.map +1 -1
- package/dist/types/Modal.js.map +1 -1
- package/dist/types/SelectMenu.d.ts +2 -6
- package/dist/types/SelectMenu.d.ts.map +1 -1
- package/dist/types/SelectMenu.js.map +1 -1
- package/dist/utils/MemoryStore.d.ts +1 -1
- package/dist/utils/MemoryStore.d.ts.map +1 -1
- package/dist/utils/MemoryStore.js +1 -1
- package/dist/utils/MemoryStore.js.map +1 -1
- package/package.json +2 -2
- package/src/DBI.ts +91 -36
- package/src/index.ts +3 -3
- package/src/methods/hookInteractionListeners.ts +8 -4
- package/src/methods/publishInteractions.ts +85 -8
- package/src/types/Button.ts +2 -2
- package/src/types/Interaction.ts +2 -0
- package/src/types/InteractionLocale.ts +28 -0
- package/src/types/Locale.ts +6 -5
- package/src/types/Modal.ts +2 -2
- package/src/types/SelectMenu.ts +2 -2
- package/src/utils/MemoryStore.ts +1 -1
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.publishInteractions = void 0;
|
|
3
|
+
exports.formatLocale = exports.localeifyOptions = exports.publishInteractions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const rest_1 = require("@discordjs/rest");
|
|
6
6
|
const v9_1 = require("discord-api-types/v9");
|
|
7
7
|
const permissions_1 = require("../utils/permissions");
|
|
8
8
|
const snakecase_keys_1 = tslib_1.__importDefault(require("snakecase-keys"));
|
|
9
9
|
const PUBLISHABLE_TYPES = ["ChatInput", "UserContextMenu", "MessageContextMenu"];
|
|
10
|
-
|
|
10
|
+
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"];
|
|
11
|
+
async function publishInteractions(clientToken, interactions, interactionsLocales, publishType, guildId) {
|
|
11
12
|
interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));
|
|
12
13
|
const rest = new rest_1.REST({ version: "9" });
|
|
13
14
|
rest.setToken(clientToken);
|
|
14
15
|
const me = await rest.get(v9_1.Routes.user());
|
|
15
|
-
|
|
16
|
+
let body = interactions.reduce((all, current) => {
|
|
16
17
|
switch (current.type) {
|
|
17
18
|
case "ChatInput": {
|
|
18
19
|
let nameSplitted = current.name.split(" ");
|
|
20
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
19
21
|
switch (nameSplitted.length) {
|
|
20
22
|
case 1: {
|
|
21
23
|
all.push({
|
|
@@ -24,24 +26,30 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
24
26
|
name: nameSplitted[0],
|
|
25
27
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
26
28
|
dm_permission: current.directMessages,
|
|
27
|
-
options: (
|
|
29
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
30
|
+
name_localizations: localeData.nameLocales(0),
|
|
31
|
+
description_localizations: localeData.descriptionLocales,
|
|
28
32
|
});
|
|
29
33
|
break;
|
|
30
34
|
}
|
|
31
35
|
case 2: {
|
|
32
36
|
let baseItem = all.find(i => i.name == current.name.split(" ")[0] && i.type == "ChatInput");
|
|
37
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
33
38
|
let option = {
|
|
34
39
|
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
35
40
|
name: nameSplitted[1],
|
|
36
41
|
description: current.description,
|
|
37
42
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
38
43
|
dm_permission: current.directMessages,
|
|
39
|
-
options: (
|
|
44
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
45
|
+
name_localizations: localeData.nameLocales(1),
|
|
46
|
+
description_localizations: localeData.descriptionLocales,
|
|
40
47
|
};
|
|
41
48
|
if (!baseItem) {
|
|
42
49
|
all.push({
|
|
43
50
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
44
51
|
name: nameSplitted[0],
|
|
52
|
+
name_localizations: localeData.nameLocales(0),
|
|
45
53
|
description: "...",
|
|
46
54
|
options: [
|
|
47
55
|
option
|
|
@@ -55,15 +63,18 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
55
63
|
}
|
|
56
64
|
case 3: {
|
|
57
65
|
let level1Item = all.find(i => i.name == current.name.split(" ")[0] && i.type == "ChatInput");
|
|
66
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
58
67
|
if (!level1Item) {
|
|
59
68
|
all.push({
|
|
60
69
|
type: v9_1.ApplicationCommandType.ChatInput,
|
|
61
70
|
name: nameSplitted[0],
|
|
71
|
+
name_localizations: localeData.nameLocales(0),
|
|
62
72
|
description: "...",
|
|
63
73
|
options: [
|
|
64
74
|
{
|
|
65
75
|
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
66
76
|
name: nameSplitted[1],
|
|
77
|
+
name_localizations: localeData.nameLocales(1),
|
|
67
78
|
description: "...",
|
|
68
79
|
options: [
|
|
69
80
|
{
|
|
@@ -72,7 +83,9 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
72
83
|
description: current.description,
|
|
73
84
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
74
85
|
dm_permission: current.directMessages,
|
|
75
|
-
options: (
|
|
86
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
87
|
+
name_localizations: localeData.nameLocales(2),
|
|
88
|
+
description_localizations: localeData.descriptionLocales,
|
|
76
89
|
}
|
|
77
90
|
]
|
|
78
91
|
}
|
|
@@ -85,6 +98,7 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
85
98
|
level1Item.options.push({
|
|
86
99
|
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
87
100
|
name: nameSplitted[1],
|
|
101
|
+
name_localizations: localeData.nameLocales(1),
|
|
88
102
|
description: "...",
|
|
89
103
|
options: [
|
|
90
104
|
{
|
|
@@ -93,7 +107,9 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
93
107
|
description: current.description,
|
|
94
108
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
95
109
|
dm_permission: current.directMessages,
|
|
96
|
-
options: (
|
|
110
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
111
|
+
name_localizations: localeData.nameLocales(2),
|
|
112
|
+
description_localizations: localeData.descriptionLocales
|
|
97
113
|
}
|
|
98
114
|
]
|
|
99
115
|
});
|
|
@@ -105,7 +121,9 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
105
121
|
description: current.description,
|
|
106
122
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
107
123
|
dm_permission: current.directMessages,
|
|
108
|
-
options: (
|
|
124
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
125
|
+
name_localizations: localeData.nameLocales(2),
|
|
126
|
+
description_localizations: localeData.descriptionLocales,
|
|
109
127
|
});
|
|
110
128
|
}
|
|
111
129
|
}
|
|
@@ -115,26 +133,33 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
115
133
|
break;
|
|
116
134
|
}
|
|
117
135
|
case "MessageContextMenu": {
|
|
136
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
118
137
|
all.push({
|
|
119
138
|
type: v9_1.ApplicationCommandType.Message,
|
|
120
139
|
name: current.name,
|
|
121
140
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
122
|
-
dm_permission: current.directMessages
|
|
141
|
+
dm_permission: current.directMessages,
|
|
142
|
+
name_localizations: localeData.allNameLocales,
|
|
143
|
+
description_localizations: localeData.descriptionLocales,
|
|
123
144
|
});
|
|
124
145
|
break;
|
|
125
146
|
}
|
|
126
147
|
case "UserContextMenu": {
|
|
148
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
127
149
|
all.push({
|
|
128
150
|
type: v9_1.ApplicationCommandType.User,
|
|
129
151
|
name: current.name,
|
|
130
152
|
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
131
|
-
dm_permission: current.directMessages
|
|
153
|
+
dm_permission: current.directMessages,
|
|
154
|
+
name_localizations: localeData.allNameLocales,
|
|
155
|
+
description_localizations: localeData.descriptionLocales
|
|
132
156
|
});
|
|
133
157
|
break;
|
|
134
158
|
}
|
|
135
159
|
}
|
|
136
160
|
return all;
|
|
137
161
|
}, []);
|
|
162
|
+
body = (0, snakecase_keys_1.default)(body);
|
|
138
163
|
switch (publishType) {
|
|
139
164
|
case "Global": {
|
|
140
165
|
await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
|
|
@@ -147,4 +172,52 @@ async function publishInteractions(clientToken, interactions, publishType, guild
|
|
|
147
172
|
}
|
|
148
173
|
}
|
|
149
174
|
exports.publishInteractions = publishInteractions;
|
|
175
|
+
function localeifyOptions(options, localeData) {
|
|
176
|
+
return options.map(i => {
|
|
177
|
+
return localeData[i.name] ? Object.assign(i, {
|
|
178
|
+
name_localizations: localeData[i.name].nameLocales,
|
|
179
|
+
description_localizations: localeData[i.name].descriptionLocales,
|
|
180
|
+
}) : i;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
exports.localeifyOptions = localeifyOptions;
|
|
184
|
+
function formatLocale(locale) {
|
|
185
|
+
let allNameLocales = {};
|
|
186
|
+
let descriptionLocales = {};
|
|
187
|
+
let optionsLocales = {};
|
|
188
|
+
function nameLocales(index) {
|
|
189
|
+
return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], i[1].split(" ").at(index)]));
|
|
190
|
+
}
|
|
191
|
+
if (!locale?.data)
|
|
192
|
+
return {
|
|
193
|
+
nameLocales,
|
|
194
|
+
allNameLocales,
|
|
195
|
+
descriptionLocales,
|
|
196
|
+
optionsLocales
|
|
197
|
+
};
|
|
198
|
+
Object.entries(locale.data).forEach(([shortLocale, localeData]) => {
|
|
199
|
+
let longAliases = ORIGINAL_LOCALES.filter(i => i.split("-").at(0) == shortLocale);
|
|
200
|
+
longAliases.forEach((longLocale) => {
|
|
201
|
+
allNameLocales[longLocale] = localeData.name;
|
|
202
|
+
descriptionLocales[longLocale] = localeData.description;
|
|
203
|
+
Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {
|
|
204
|
+
if (!optionsLocales[optionName])
|
|
205
|
+
optionsLocales[optionName] = {};
|
|
206
|
+
if (!optionsLocales[optionName].nameLocales)
|
|
207
|
+
optionsLocales[optionName].nameLocales = {};
|
|
208
|
+
if (!optionsLocales[optionName].descriptionLocales)
|
|
209
|
+
optionsLocales[optionName].descriptionLocales = {};
|
|
210
|
+
optionsLocales[optionName].nameLocales[longLocale] = optionData.name;
|
|
211
|
+
optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
nameLocales,
|
|
217
|
+
allNameLocales,
|
|
218
|
+
descriptionLocales,
|
|
219
|
+
optionsLocales
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
exports.formatLocale = formatLocale;
|
|
150
223
|
//# sourceMappingURL=publishInteractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AACzD,4EAA2C;AAE3C,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AAE1E,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,YAAsD,EACtD,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5E,MAAM,IAAI,GAAG,IAAI,WAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE3B,MAAM,EAAE,GAAyB,MAAM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AApJD,kDAoJC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n const body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1] && i.type == \"ChatInput\");\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}"]}
|
|
1
|
+
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AACzD,4EAA2C;AAI3C,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AACjF,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE5N,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,YAAsD,EACtD,mBAAqE,EACrE,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5E,MAAM,IAAI,GAAG,I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c,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACrE,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACrF,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAtCD,oCAsCC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\nconst 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\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n interactionsLocales: Discord.Collection<string, DBIInteractionLocale>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n let body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(0),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(1),\r\n description_localizations: localeData.descriptionLocales,\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1] && i.type == \"ChatInput\");\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n body = snakecaseKeys(body);\r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}\r\n\r\nexport function localeifyOptions(options: any[], localeData: any): any[] {\r\n return options.map(i => {\r\n return localeData[i.name] ? Object.assign(i, {\r\n name_localizations: localeData[i.name].nameLocales,\r\n description_localizations: localeData[i.name].descriptionLocales,\r\n }) : i;\r\n })\r\n}\r\n\r\nexport function formatLocale(locale: DBIInteractionLocale): any {\r\n let allNameLocales = {};\r\n let descriptionLocales = {};\r\n let optionsLocales = {};\r\n\r\n function nameLocales(index) {\r\n return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], (i[1] as string).split(\" \").at(index)]));\r\n }\r\n\r\n if (!locale?.data) return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n };\r\n\r\n Object.entries(locale.data).forEach(([shortLocale, localeData]) => {\r\n let longAliases = ORIGINAL_LOCALES.filter(i => i.split(\"-\").at(0) == shortLocale);\r\n longAliases.forEach((longLocale) => {\r\n allNameLocales[longLocale] = localeData.name;\r\n descriptionLocales[longLocale] = localeData.description;\r\n Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {\r\n if (!optionsLocales[optionName]) optionsLocales[optionName] = {};\r\n if (!optionsLocales[optionName].nameLocales) optionsLocales[optionName].nameLocales = {};\r\n if (!optionsLocales[optionName].descriptionLocales) optionsLocales[optionName].descriptionLocales = {};\r\n\r\n optionsLocales[optionName].nameLocales[longLocale] = optionData.name;\r\n optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;\r\n })\r\n });\r\n });\r\n \r\n return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n }\r\n}"]}
|
package/dist/types/Button.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import { DBI } from "../DBI";
|
|
3
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx } from "./Interaction";
|
|
3
|
+
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
4
|
export interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {
|
|
5
5
|
interaction: Discord.ButtonInteraction<Discord.CacheType>;
|
|
6
|
-
data:
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
$ref: string;
|
|
9
|
-
$unRef(): boolean;
|
|
10
|
-
} | string | number)[];
|
|
6
|
+
data: TDBIReferencedData[];
|
|
11
7
|
}
|
|
12
8
|
export declare type TDBIButtonOmitted = Omit<DBIButton, "type" | "description" | "dbi" | "toJSON">;
|
|
13
9
|
export declare class DBIButton extends DBIBaseInteraction {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAE3F,qBAAa,SAAU,SAAQ,kBAAkB;gBACnC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB;IAOrC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC;IAE/D,SAAS,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEjE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,mBAAmB;CAOjF"}
|
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,+
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,SAAU,SAAQ,gCAAkB;IAC/C,YAAY,GAAQ,EAAE,IAAuB;QAC3C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAyB,IAAwB,CAAC;IAAA,CAAC;IAEtE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAnBD,8BAmBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\n\r\nexport interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<Discord.CacheType>;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIButtonOmitted = Omit<DBIButton, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIButton extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIButtonOmitted) {\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): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.Button\r\n } as any;\r\n };\r\n}"]}
|
|
@@ -11,6 +11,11 @@ export interface IDBIBaseExecuteCtx {
|
|
|
11
11
|
setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;
|
|
12
12
|
other: Record<string, any>;
|
|
13
13
|
}
|
|
14
|
+
export declare type TDBIReferencedData = ({
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
$ref: string;
|
|
17
|
+
$unRef(): boolean;
|
|
18
|
+
} | string | number);
|
|
14
19
|
export declare type TDBIInteractionTypes = "ChatInput" | "UserContextMenu" | "MessageContextMenu" | "Modal" | "Autocomplete" | "SelectMenu" | "Button";
|
|
15
20
|
export declare type TDBIRateLimitTypes = "User" | "Channel" | "Guild" | "Member" | "Message";
|
|
16
21
|
export declare type DBIRateLimit = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interaction.d.ts","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,kBAAkB;IACjC,WAAW,EACP,OAAO,CAAC,2BAA2B,GACnC,OAAO,CAAC,iCAAiC,GACzC,OAAO,CAAC,oCAAoC,GAC5C,OAAO,CAAC,sBAAsB,GAC9B,OAAO,CAAC,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAC9B,MAAM,EAAE;QACN,IAAI,EAAE,SAAS,CAAC;QAChB,KAAK,CAAC,EAAE,SAAS,CAAA;KAClB,CAAA;IACD,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACvE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,oBAAY,oBAAoB,GAC5B,WAAW,GACX,iBAAiB,GACjB,oBAAoB,GACpB,OAAO,GACP,cAAc,GACd,YAAY,GACZ,QAAQ,CAAC;AAEb,oBAAY,kBAAkB,GAC1B,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../../src/types/Interaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Interaction.js","sourceRoot":"","sources":["../../src/types/Interaction.ts"],"names":[],"mappings":";;;AAiDA,MAAa,kBAAkB;IAC7B,YAAY,GAAQ,EAAE,GAAoC;QACxD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,GAAG,CAAM;IACT,IAAI,CAAS;IACb,WAAW,CAAS;IACX,IAAI,CAAuB;IACpC,OAAO,CAAe;IACtB,KAAK,CAAuB;IAC5B,UAAU,CAAkB;IAC5B,SAAS,CAAC,GAAuB;IAEjC,CAAC;CACF;AArBD,gDAqBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBILocale } from \"./Locale\";\r\n\r\nexport interface IDBIBaseExecuteCtx {\r\n interaction:\r\n | Discord.ChatInputCommandInteraction\r\n | Discord.UserContextMenuCommandInteraction\r\n | Discord.MessageContextMenuCommandInteraction\r\n | Discord.ModalSubmitInteraction\r\n | Discord.AutocompleteInteraction\r\n | Discord.SelectMenuInteraction\r\n | Discord.ButtonInteraction;\r\n locale: {\r\n user: DBILocale,\r\n guild?: DBILocale\r\n }\r\n dbi: DBI;\r\n setRateLimit(type: TDBIRateLimitTypes, duration: number): Promise<any>;\r\n other: Record<string, any>;\r\n}\r\n\r\nexport type TDBIReferencedData = ({ [key: string]: any, $ref: string, $unRef(): boolean } | string | number);\r\n\r\nexport type TDBIInteractionTypes =\r\n | \"ChatInput\"\r\n | \"UserContextMenu\"\r\n | \"MessageContextMenu\"\r\n | \"Modal\"\r\n | \"Autocomplete\"\r\n | \"SelectMenu\"\r\n | \"Button\";\r\n\r\nexport type TDBIRateLimitTypes =\r\n | \"User\"\r\n | \"Channel\"\r\n | \"Guild\"\r\n | \"Member\"\r\n | \"Message\";\r\n\r\n\r\nexport type DBIRateLimit = {\r\n type: TDBIRateLimitTypes;\r\n /**\r\n * Duration in milliseconds.\r\n */\r\n duration: number;\r\n}\r\n\r\nexport class DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: Omit<DBIBaseInteraction, \"dbi\">) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.description = cfg.description;\r\n this.onExecute = cfg.onExecute;\r\n this.type = cfg.type;\r\n this.options = cfg.options;\r\n this.other = cfg.other;\r\n }\r\n\r\n dbi: DBI;\r\n name: string;\r\n description: string;\r\n readonly type: TDBIInteractionTypes;\r\n options?: any | any[];\r\n other?: Record<string, any>;\r\n rateLimits?: DBIRateLimit[];\r\n onExecute(ctx: IDBIBaseExecuteCtx): Promise<any> | any {\r\n\r\n }\r\n}"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DBI } from "../DBI";
|
|
2
|
+
import { TDBILocaleString } from "./Locale";
|
|
3
|
+
export declare type TDBIInteractionLocaleData = {
|
|
4
|
+
[K in TDBILocaleString]?: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
options?: {
|
|
8
|
+
[k: string]: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, "dbi">;
|
|
16
|
+
export declare class DBIInteractionLocale {
|
|
17
|
+
name: string;
|
|
18
|
+
data: TDBIInteractionLocaleData;
|
|
19
|
+
dbi: DBI;
|
|
20
|
+
constructor(dbi: any, cfg: TDBIInteractionLocaleOmitted);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=InteractionLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionLocale.d.ts","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE;YACR,CAAC,CAAC,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;aACrB,CAAA;SACF,CAAA;KACF;CACF,CAAC;AAEF,oBAAY,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAE7E,qBAAa,oBAAoB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,yBAAyB,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;gBACG,GAAG,KAAA,EAAE,GAAG,EAAE,4BAA4B;CAKnD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DBIInteractionLocale = void 0;
|
|
4
|
+
class DBIInteractionLocale {
|
|
5
|
+
name;
|
|
6
|
+
data;
|
|
7
|
+
dbi;
|
|
8
|
+
constructor(dbi, cfg) {
|
|
9
|
+
this.dbi = dbi;
|
|
10
|
+
this.name = cfg.name;
|
|
11
|
+
this.data = cfg.data;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DBIInteractionLocale = DBIInteractionLocale;
|
|
15
|
+
//# sourceMappingURL=InteractionLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionLocale.js","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":";;;AAkBA,MAAa,oBAAoB;IAC/B,IAAI,CAAS;IACb,IAAI,CAA4B;IAChC,GAAG,CAAM;IACT,YAAY,GAAG,EAAE,GAAiC;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AATD,oDASC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { TDBILocaleString } from \"./Locale\";\r\n\r\nexport type TDBIInteractionLocaleData = {\r\n [K in TDBILocaleString]?: {\r\n name: string;\r\n description: string;\r\n options?: {\r\n [k: string]: {\r\n name: string;\r\n description: string;\r\n }\r\n }\r\n };\r\n};\r\n\r\nexport type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, \"dbi\">;\r\n\r\nexport class DBIInteractionLocale {\r\n name: string;\r\n data: TDBIInteractionLocaleData;\r\n dbi: DBI;\r\n constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.data = cfg.data;\r\n }\r\n}"]}
|
package/dist/types/Locale.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export interface LangConstructorObject {
|
|
|
6
6
|
[property: string]: LangConstructorObject | string;
|
|
7
7
|
}
|
|
8
8
|
export declare 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";
|
|
9
|
-
export declare type TDBILocaleConstructor = Omit<DBILocale & {
|
|
9
|
+
export declare type TDBILocaleConstructor = Omit<DBILocale, "data" | "dbi"> & {
|
|
10
10
|
data: LangConstructorObject;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
export declare class DBILocale {
|
|
13
13
|
name: TDBILocaleString;
|
|
14
14
|
data: LangObject;
|
|
@@ -16,4 +16,5 @@ export declare class DBILocale {
|
|
|
16
16
|
dbi: DBI;
|
|
17
17
|
constructor(dbi: DBI, cfg: TDBILocaleConstructor);
|
|
18
18
|
}
|
|
19
|
+
export declare function convertLang(data: LangConstructorObject): LangObject;
|
|
19
20
|
//# sourceMappingURL=Locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Locale.d.ts","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,WAAW,UAAU;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,MAAM,CAAC;CACpD;AAED,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1N,oBAAY,qBAAqB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAEtG,qBAAa,SAAS;IACpB,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,CAAC,KAAK,CAAwB;IACrC,GAAG,EAAE,GAAG,CAAC;gBACG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,qBAAqB;CAMjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,UAAU,CAUnE"}
|
package/dist/types/Locale.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DBILocale = void 0;
|
|
3
|
+
exports.convertLang = exports.DBILocale = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
const stuffs = tslib_1.__importStar(require("stuffs"));
|
|
6
7
|
class DBILocale {
|
|
7
8
|
name;
|
|
@@ -12,11 +13,11 @@ class DBILocale {
|
|
|
12
13
|
this.dbi = dbi;
|
|
13
14
|
this.name = cfg.name;
|
|
14
15
|
this._data = cfg.data;
|
|
15
|
-
this.data =
|
|
16
|
+
this.data = convertLang(cfg.data);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
exports.DBILocale = DBILocale;
|
|
19
|
-
function
|
|
20
|
+
function convertLang(data) {
|
|
20
21
|
return Object.fromEntries(Object.entries(data).map(([key, value]) => {
|
|
21
22
|
if (typeof value === "string") {
|
|
22
23
|
return [key, (...args) => {
|
|
@@ -24,8 +25,9 @@ function convert(data) {
|
|
|
24
25
|
}];
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
|
-
return [key,
|
|
28
|
+
return [key, convertLang(value)];
|
|
28
29
|
}
|
|
29
30
|
}));
|
|
30
31
|
}
|
|
32
|
+
exports.convertLang = convertLang;
|
|
31
33
|
//# sourceMappingURL=Locale.js.map
|
package/dist/types/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AAejC,MAAa,SAAS;IACpB,IAAI,CAAmB;IACvB,IAAI,CAAY;IACR,KAAK,CAAwB;IACrC,GAAG,CAAM;IACT,YAAY,GAAQ,EAAE,GAA0B;QAC9C,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,
|
|
1
|
+
{"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/types/Locale.ts"],"names":[],"mappings":";;;;AAAA,aAAa;AACb,uDAAiC;AAejC,MAAa,SAAS;IACpB,IAAI,CAAmB;IACvB,IAAI,CAAY;IACR,KAAK,CAAwB;IACrC,GAAG,CAAM;IACT,YAAY,GAAQ,EAAE,GAA0B;QAC9C,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,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAXD,8BAWC;AAED,SAAgB,WAAW,CAAC,IAA2B;IACrD,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,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBACxF,CAAC,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC,CAAA;AACL,CAAC;AAVD,kCAUC","sourcesContent":["// @ts-ignore\r\nimport * as stuffs from \"stuffs\";\r\nimport { DBI } from \"../DBI\";\r\n\r\nexport interface LangObject {\r\n [property: string]: LangObject & ((...args: any[]) => string);\r\n}\r\n\r\nexport interface LangConstructorObject {\r\n [property: string]: LangConstructorObject | 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 = Omit<DBILocale, \"data\" | \"dbi\"> & { data: LangConstructorObject };\r\n\r\nexport class DBILocale {\r\n name: TDBILocaleString;\r\n data: LangObject\r\n private _data: LangConstructorObject;\r\n dbi: DBI;\r\n constructor(dbi: DBI, cfg: TDBILocaleConstructor) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this._data = cfg.data;\r\n this.data = convertLang(cfg.data);\r\n }\r\n}\r\n\r\nexport function convertLang(data: LangConstructorObject): LangObject {\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, Object.fromEntries(args.map((t, i) => [`{${i}}`, t])))\r\n }]\r\n } else {\r\n return [key, convertLang(value)];\r\n }\r\n }))\r\n}\r\n"]}
|
package/dist/types/Modal.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { DBI } from "../DBI";
|
|
2
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx } from "./Interaction";
|
|
2
|
+
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
3
3
|
import Discord from "discord.js";
|
|
4
4
|
export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
|
|
5
5
|
interaction: Discord.ModalSubmitInteraction<Discord.CacheType>;
|
|
6
|
-
data:
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
$ref: string;
|
|
9
|
-
$unRef(): boolean;
|
|
10
|
-
} | string | number)[];
|
|
6
|
+
data: TDBIReferencedData[];
|
|
11
7
|
}
|
|
12
8
|
export declare type TDBIModalOmitted = Omit<DBIModal, "type" | "description" | "dbi" | "toJSON">;
|
|
13
9
|
export declare class DBIModal extends DBIBaseInteraction {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/D,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzF,qBAAa,QAAS,SAAQ,kBAAkB;gBAClC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB;IAOnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IAErD,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEhE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,kBAAkB;CAMhF"}
|
package/dist/types/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAUpD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,GAAqB;QACzC,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAErE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;SACpD,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAlBD,4BAkBC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\n\r\nexport interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ModalSubmitInteraction<Discord.CacheType>;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"Modal\"\r\n })\r\n }\r\n\r\n declare options: Omit<Discord.ModalComponentData, \"customId\">;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData)\r\n } as any;\r\n };\r\n}"]}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import { DBI } from "../DBI";
|
|
3
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx } from "./Interaction";
|
|
3
|
+
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
4
|
export interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {
|
|
5
5
|
interaction: Discord.ButtonInteraction<Discord.CacheType>;
|
|
6
|
-
data:
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
$ref: string;
|
|
9
|
-
$unRef(): boolean;
|
|
10
|
-
})[];
|
|
6
|
+
data: TDBIReferencedData[];
|
|
11
7
|
}
|
|
12
8
|
export declare type TDBISelectMenuOmitted = Omit<DBIBaseInteraction, "type" | "description" | "dbi" | "toJSON">;
|
|
13
9
|
export declare class DBISelectMenu extends DBIBaseInteraction {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenu.d.ts","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectMenu.d.ts","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,qBAAqB,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAExG,qBAAa,aAAc,SAAQ,kBAAkB;gBACvC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB;IAOzC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC;IAEnE,SAAS,CAAC,GAAG,EAAE,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAErE,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,uBAAuB;CAOrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+
|
|
1
|
+
{"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AASpD,MAAa,aAAc,SAAQ,gCAAkB;IACnD,YAAY,GAAQ,EAAE,IAA2B;QAC/C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAA6B,IAAwB,CAAC;IAAA,CAAC;IAE1E,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;YAC1D,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAA;IACV,CAAC;IAAA,CAAC;CACH;AAnBD,sCAmBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from \"./Interaction\";\r\nimport { customIdBuilder } from \"../utils/customId\";\r\n\r\nexport interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<Discord.CacheType>;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted = Omit<DBIBaseInteraction, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBISelectMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBISelectMenuOmitted) {\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.SelectMenuComponentData, \"customId\" | \"type\">;\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {\r\n return {\r\n ...this.options,\r\n customId: customIdBuilder(this.dbi, this.name, customData),\r\n type: Discord.ComponentType.SelectMenu\r\n } as any\r\n };\r\n}"]}
|
|
@@ -3,7 +3,7 @@ export declare class MemoryStore {
|
|
|
3
3
|
constructor();
|
|
4
4
|
get(key: string, defaultValue?: any): Promise<any>;
|
|
5
5
|
set(key: string, value: any): Promise<any>;
|
|
6
|
-
|
|
6
|
+
delete(key: string): Promise<boolean>;
|
|
7
7
|
has(key: string): Promise<boolean>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=MemoryStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IASlD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C,
|
|
1
|
+
{"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IASlD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryStore.js","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":";;;;AAAA,4DAAuB;AAEvB,MAAa,WAAW;IACtB,KAAK,CAAsB;IAC3B;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,YAAkB;QACvC,IAAI,GAAG,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE;YACR,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAC5B,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU;QAC/B,OAAO,IAAI,CAAC,KAAK,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"MemoryStore.js","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":";;;;AAAA,4DAAuB;AAEvB,MAAa,WAAW;IACtB,KAAK,CAAsB;IAC3B;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,YAAkB;QACvC,IAAI,GAAG,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE;YACR,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAC5B,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU;QAC/B,OAAO,IAAI,CAAC,KAAK,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,OAAO,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACF;AAzBD,kCAyBC","sourcesContent":["import _ from \"lodash\";\r\n\r\nexport class MemoryStore {\r\n store: Record<string, any>;\r\n constructor() {\r\n this.store = {};\r\n }\r\n async get(key: string, defaultValue?: any): Promise<any> {\r\n let val = _.get(this.store, key);\r\n if (!val) {\r\n this.set(key, defaultValue);\r\n return defaultValue;\r\n }\r\n return val;\r\n }\r\n\r\n async set(key: string, value: any): Promise<any> {\r\n return this.store = _.set(this.store, key, value);\r\n }\r\n\r\n async delete(key: string): Promise<boolean> {\r\n return _.unset(this.store, key);\r\n }\r\n\r\n async has(key: string): Promise<boolean> {\r\n return _.has(this.store, key);\r\n }\r\n}"]}
|