@mostfeatured/dbi 0.0.53 → 0.0.55
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 +156 -156
- package/dist/DBI.js +332 -332
- package/dist/Events.d.ts +53 -53
- package/dist/Events.js +58 -58
- package/dist/data/eventMap.json +234 -234
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -16
- package/dist/methods/hookEventListeners.d.ts +3 -3
- package/dist/methods/hookEventListeners.js +87 -87
- package/dist/methods/hookInteractionListeners.d.ts +3 -3
- package/dist/methods/hookInteractionListeners.js +118 -118
- package/dist/methods/publishInteractions.d.ts +7 -7
- package/dist/methods/publishInteractions.js +238 -238
- package/dist/types/Button.d.ts +18 -16
- package/dist/types/Button.d.ts.map +1 -1
- package/dist/types/Button.js +31 -27
- package/dist/types/Button.js.map +1 -1
- package/dist/types/ButtonBuilder.d.ts +30 -0
- package/dist/types/ButtonBuilder.d.ts.map +1 -0
- package/dist/types/ButtonBuilder.js +43 -0
- package/dist/types/ButtonBuilder.js.map +1 -0
- package/dist/types/ChatInput/ChatInput.d.ts +15 -15
- package/dist/types/ChatInput/ChatInput.js +20 -20
- package/dist/types/ChatInput/ChatInputOptions.d.ts +162 -161
- package/dist/types/ChatInput/ChatInputOptions.d.ts.map +1 -1
- package/dist/types/ChatInput/ChatInputOptions.js +161 -160
- package/dist/types/ChatInput/ChatInputOptions.js.map +1 -1
- package/dist/types/CustomEvent.d.ts +13 -13
- package/dist/types/CustomEvent.js +19 -19
- package/dist/types/Event.d.ts +263 -263
- package/dist/types/Event.js +22 -22
- package/dist/types/Interaction.d.ts +47 -47
- package/dist/types/Interaction.js +24 -24
- package/dist/types/InteractionLocale.d.ts +25 -25
- package/dist/types/InteractionLocale.js +14 -14
- package/dist/types/Locale.d.ts +21 -21
- package/dist/types/Locale.js +38 -38
- package/dist/types/MessageContextMenu.d.ts +14 -14
- package/dist/types/MessageContextMenu.js +18 -18
- package/dist/types/Modal.d.ts +22 -20
- package/dist/types/Modal.d.ts.map +1 -1
- package/dist/types/Modal.js +29 -25
- package/dist/types/Modal.js.map +1 -1
- package/dist/types/ModalBuilder.d.ts +31 -0
- package/dist/types/ModalBuilder.d.ts.map +1 -0
- package/dist/types/ModalBuilder.js +43 -0
- package/dist/types/ModalBuilder.js.map +1 -0
- package/dist/types/SelectMenu.d.ts +18 -16
- package/dist/types/SelectMenu.d.ts.map +1 -1
- package/dist/types/SelectMenu.js +31 -27
- package/dist/types/SelectMenu.js.map +1 -1
- package/dist/types/SelectMenuBuilder.d.ts +28 -0
- package/dist/types/SelectMenuBuilder.d.ts.map +1 -0
- package/dist/types/SelectMenuBuilder.js +43 -0
- package/dist/types/SelectMenuBuilder.js.map +1 -0
- package/dist/types/UserContextMenu.d.ts +14 -14
- package/dist/types/UserContextMenu.js +18 -18
- package/dist/utils/MemoryStore.d.ts +8 -8
- package/dist/utils/MemoryStore.js +29 -29
- package/dist/utils/UtilTypes.d.ts +7 -7
- package/dist/utils/UtilTypes.d.ts.map +1 -1
- package/dist/utils/UtilTypes.js +2 -2
- package/dist/utils/UtilTypes.js.map +1 -1
- package/dist/utils/customId.d.ts +7 -7
- package/dist/utils/customId.js +45 -45
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/permissions.js +8 -8
- package/dist/utils/recursiveImport.d.ts +4 -4
- package/dist/utils/recursiveImport.js +26 -26
- package/package.json +2 -2
- package/src/types/Button.ts +7 -2
- package/src/types/ButtonBuilder.ts +52 -0
- package/src/types/ChatInput/ChatInputOptions.ts +1 -0
- package/src/types/Modal.ts +8 -2
- package/src/types/ModalBuilder.ts +52 -0
- package/src/types/SelectMenu.ts +8 -2
- package/src/types/SelectMenuBuilder.ts +52 -0
- package/src/utils/UtilTypes.ts +1 -1
|
@@ -1,239 +1,239 @@
|
|
|
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
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
42
|
-
dm_permission: current.directMessages,
|
|
43
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
44
|
-
name_localizations: localeData.nameLocales(1),
|
|
45
|
-
description_localizations: localeData.descriptionLocales,
|
|
46
|
-
};
|
|
47
|
-
if (!baseItem) {
|
|
48
|
-
all.push({
|
|
49
|
-
type: v9_1.ApplicationCommandType.ChatInput,
|
|
50
|
-
name: nameSplitted[0],
|
|
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
|
-
description: "...",
|
|
72
|
-
options: [
|
|
73
|
-
{
|
|
74
|
-
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
75
|
-
name: nameSplitted[1],
|
|
76
|
-
name_localizations: localeData.nameLocales(1),
|
|
77
|
-
description: "...",
|
|
78
|
-
options: [
|
|
79
|
-
{
|
|
80
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
81
|
-
name: nameSplitted[2],
|
|
82
|
-
description: current.description,
|
|
83
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
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
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
108
|
-
dm_permission: current.directMessages,
|
|
109
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
110
|
-
name_localizations: localeData.nameLocales(2),
|
|
111
|
-
description_localizations: localeData.descriptionLocales
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
level2Item.options.push({
|
|
118
|
-
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
119
|
-
name: nameSplitted[2],
|
|
120
|
-
description: current.description,
|
|
121
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
122
|
-
dm_permission: current.directMessages,
|
|
123
|
-
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
124
|
-
name_localizations: localeData.nameLocales(2),
|
|
125
|
-
description_localizations: localeData.descriptionLocales,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
case "MessageContextMenu": {
|
|
135
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
136
|
-
all.push({
|
|
137
|
-
type: v9_1.ApplicationCommandType.Message,
|
|
138
|
-
name: current.name,
|
|
139
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
140
|
-
dm_permission: current.directMessages,
|
|
141
|
-
name_localizations: localeData.allNameLocales,
|
|
142
|
-
description_localizations: localeData.descriptionLocales,
|
|
143
|
-
});
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case "UserContextMenu": {
|
|
147
|
-
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
148
|
-
all.push({
|
|
149
|
-
type: v9_1.ApplicationCommandType.User,
|
|
150
|
-
name: current.name,
|
|
151
|
-
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
152
|
-
dm_permission: current.directMessages,
|
|
153
|
-
name_localizations: localeData.allNameLocales,
|
|
154
|
-
description_localizations: localeData.descriptionLocales
|
|
155
|
-
});
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return all;
|
|
160
|
-
}, []);
|
|
161
|
-
switch (publishType) {
|
|
162
|
-
case "Guild": {
|
|
163
|
-
await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case "Global": {
|
|
167
|
-
await rest.put(v9_1.Routes.applicationCommands(me.id), { body });
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.publishInteractions = publishInteractions;
|
|
173
|
-
function localeifyOptions(options, localeData) {
|
|
174
|
-
return options.map(i => {
|
|
175
|
-
let optionData = localeData[i.name];
|
|
176
|
-
return optionData ? Object.assign(i, {
|
|
177
|
-
name_localizations: optionData.nameLocales,
|
|
178
|
-
description_localizations: optionData.descriptionLocales,
|
|
179
|
-
choices: i.choices ? i.choices.map((j) => {
|
|
180
|
-
let choiceLocale = optionData.choiceLocales[j.name];
|
|
181
|
-
return choiceLocale ? Object.assign(j, {
|
|
182
|
-
name_localizations: choiceLocale
|
|
183
|
-
}) : j;
|
|
184
|
-
}) : undefined
|
|
185
|
-
}) : i;
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
exports.localeifyOptions = localeifyOptions;
|
|
189
|
-
function formatLocale(locale) {
|
|
190
|
-
let allNameLocales = {};
|
|
191
|
-
let descriptionLocales = {};
|
|
192
|
-
let optionsLocales = {};
|
|
193
|
-
function nameLocales(index) {
|
|
194
|
-
return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], i[1].split(" ").at(index)]));
|
|
195
|
-
}
|
|
196
|
-
if (!locale?.data)
|
|
197
|
-
return {
|
|
198
|
-
nameLocales,
|
|
199
|
-
allNameLocales,
|
|
200
|
-
descriptionLocales,
|
|
201
|
-
optionsLocales
|
|
202
|
-
};
|
|
203
|
-
Object.entries(locale.data).forEach(([shortLocale, localeData]) => {
|
|
204
|
-
let longAliases = ORIGINAL_LOCALES.filter(i => i.split("-").at(0) == shortLocale);
|
|
205
|
-
longAliases.forEach((longLocale) => {
|
|
206
|
-
allNameLocales[longLocale] = localeData.name;
|
|
207
|
-
descriptionLocales[longLocale] = localeData.description;
|
|
208
|
-
Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
|
|
209
|
-
if (!optionsLocales[optionName])
|
|
210
|
-
optionsLocales[optionName] = {};
|
|
211
|
-
let optionLocale = optionsLocales[optionName];
|
|
212
|
-
if (!optionLocale.nameLocales)
|
|
213
|
-
optionLocale.nameLocales = {};
|
|
214
|
-
if (!optionLocale.descriptionLocales)
|
|
215
|
-
optionLocale.descriptionLocales = {};
|
|
216
|
-
if (!optionLocale.choiceLocales)
|
|
217
|
-
optionLocale.choiceLocales = {};
|
|
218
|
-
Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
|
|
219
|
-
if (!optionLocale.choiceLocales)
|
|
220
|
-
optionLocale.choiceLocales = {};
|
|
221
|
-
if (!optionLocale.choiceLocales[choiceOriginalName])
|
|
222
|
-
optionLocale.choiceLocales[choiceOriginalName] = {};
|
|
223
|
-
let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
|
|
224
|
-
choiceLocale[longLocale] = choiceName;
|
|
225
|
-
});
|
|
226
|
-
optionLocale.nameLocales[longLocale] = optionData.name;
|
|
227
|
-
optionLocale.descriptionLocales[longLocale] = optionData.description;
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
return {
|
|
232
|
-
nameLocales,
|
|
233
|
-
allNameLocales,
|
|
234
|
-
descriptionLocales,
|
|
235
|
-
optionsLocales
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
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
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
42
|
+
dm_permission: current.directMessages,
|
|
43
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
44
|
+
name_localizations: localeData.nameLocales(1),
|
|
45
|
+
description_localizations: localeData.descriptionLocales,
|
|
46
|
+
};
|
|
47
|
+
if (!baseItem) {
|
|
48
|
+
all.push({
|
|
49
|
+
type: v9_1.ApplicationCommandType.ChatInput,
|
|
50
|
+
name: nameSplitted[0],
|
|
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
|
+
description: "...",
|
|
72
|
+
options: [
|
|
73
|
+
{
|
|
74
|
+
type: v9_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
75
|
+
name: nameSplitted[1],
|
|
76
|
+
name_localizations: localeData.nameLocales(1),
|
|
77
|
+
description: "...",
|
|
78
|
+
options: [
|
|
79
|
+
{
|
|
80
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
81
|
+
name: nameSplitted[2],
|
|
82
|
+
description: current.description,
|
|
83
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
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
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
108
|
+
dm_permission: current.directMessages,
|
|
109
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
110
|
+
name_localizations: localeData.nameLocales(2),
|
|
111
|
+
description_localizations: localeData.descriptionLocales
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
level2Item.options.push({
|
|
118
|
+
type: v9_1.ApplicationCommandOptionType.Subcommand,
|
|
119
|
+
name: nameSplitted[2],
|
|
120
|
+
description: current.description,
|
|
121
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
122
|
+
dm_permission: current.directMessages,
|
|
123
|
+
options: localeifyOptions(current.options || [], localeData.optionsLocales),
|
|
124
|
+
name_localizations: localeData.nameLocales(2),
|
|
125
|
+
description_localizations: localeData.descriptionLocales,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "MessageContextMenu": {
|
|
135
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
136
|
+
all.push({
|
|
137
|
+
type: v9_1.ApplicationCommandType.Message,
|
|
138
|
+
name: current.name,
|
|
139
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
140
|
+
dm_permission: current.directMessages,
|
|
141
|
+
name_localizations: localeData.allNameLocales,
|
|
142
|
+
description_localizations: localeData.descriptionLocales,
|
|
143
|
+
});
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "UserContextMenu": {
|
|
147
|
+
let localeData = formatLocale(interactionsLocales.get(current.name) ?? {});
|
|
148
|
+
all.push({
|
|
149
|
+
type: v9_1.ApplicationCommandType.User,
|
|
150
|
+
name: current.name,
|
|
151
|
+
default_member_permissions: (0, permissions_1.reducePermissions)(current.defaultMemberPermissions).toString(),
|
|
152
|
+
dm_permission: current.directMessages,
|
|
153
|
+
name_localizations: localeData.allNameLocales,
|
|
154
|
+
description_localizations: localeData.descriptionLocales
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return all;
|
|
160
|
+
}, []);
|
|
161
|
+
switch (publishType) {
|
|
162
|
+
case "Guild": {
|
|
163
|
+
await rest.put(v9_1.Routes.applicationGuildCommands(me.id, guildId), { body });
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case "Global": {
|
|
167
|
+
await rest.put(v9_1.Routes.applicationCommands(me.id), { body });
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.publishInteractions = publishInteractions;
|
|
173
|
+
function localeifyOptions(options, localeData) {
|
|
174
|
+
return options.map(i => {
|
|
175
|
+
let optionData = localeData[i.name];
|
|
176
|
+
return optionData ? Object.assign(i, {
|
|
177
|
+
name_localizations: optionData.nameLocales,
|
|
178
|
+
description_localizations: optionData.descriptionLocales,
|
|
179
|
+
choices: i.choices ? i.choices.map((j) => {
|
|
180
|
+
let choiceLocale = optionData.choiceLocales[j.name];
|
|
181
|
+
return choiceLocale ? Object.assign(j, {
|
|
182
|
+
name_localizations: choiceLocale
|
|
183
|
+
}) : j;
|
|
184
|
+
}) : undefined
|
|
185
|
+
}) : i;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
exports.localeifyOptions = localeifyOptions;
|
|
189
|
+
function formatLocale(locale) {
|
|
190
|
+
let allNameLocales = {};
|
|
191
|
+
let descriptionLocales = {};
|
|
192
|
+
let optionsLocales = {};
|
|
193
|
+
function nameLocales(index) {
|
|
194
|
+
return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], i[1].split(" ").at(index)]));
|
|
195
|
+
}
|
|
196
|
+
if (!locale?.data)
|
|
197
|
+
return {
|
|
198
|
+
nameLocales,
|
|
199
|
+
allNameLocales,
|
|
200
|
+
descriptionLocales,
|
|
201
|
+
optionsLocales
|
|
202
|
+
};
|
|
203
|
+
Object.entries(locale.data).forEach(([shortLocale, localeData]) => {
|
|
204
|
+
let longAliases = ORIGINAL_LOCALES.filter(i => i.split("-").at(0) == shortLocale);
|
|
205
|
+
longAliases.forEach((longLocale) => {
|
|
206
|
+
allNameLocales[longLocale] = localeData.name;
|
|
207
|
+
descriptionLocales[longLocale] = localeData.description;
|
|
208
|
+
Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
|
|
209
|
+
if (!optionsLocales[optionName])
|
|
210
|
+
optionsLocales[optionName] = {};
|
|
211
|
+
let optionLocale = optionsLocales[optionName];
|
|
212
|
+
if (!optionLocale.nameLocales)
|
|
213
|
+
optionLocale.nameLocales = {};
|
|
214
|
+
if (!optionLocale.descriptionLocales)
|
|
215
|
+
optionLocale.descriptionLocales = {};
|
|
216
|
+
if (!optionLocale.choiceLocales)
|
|
217
|
+
optionLocale.choiceLocales = {};
|
|
218
|
+
Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
|
|
219
|
+
if (!optionLocale.choiceLocales)
|
|
220
|
+
optionLocale.choiceLocales = {};
|
|
221
|
+
if (!optionLocale.choiceLocales[choiceOriginalName])
|
|
222
|
+
optionLocale.choiceLocales[choiceOriginalName] = {};
|
|
223
|
+
let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
|
|
224
|
+
choiceLocale[longLocale] = choiceName;
|
|
225
|
+
});
|
|
226
|
+
optionLocale.nameLocales[longLocale] = optionData.name;
|
|
227
|
+
optionLocale.descriptionLocales[longLocale] = optionData.description;
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
nameLocales,
|
|
233
|
+
allNameLocales,
|
|
234
|
+
descriptionLocales,
|
|
235
|
+
optionsLocales
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
exports.formatLocale = formatLocale;
|
|
239
239
|
//# sourceMappingURL=publishInteractions.js.map
|
package/dist/types/Button.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import Discord from "discord.js";
|
|
2
|
-
import { DBI } from "../DBI";
|
|
3
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
|
-
import { IDBIToJSONArgs } from "../utils/UtilTypes";
|
|
5
|
-
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import Discord from "discord.js";
|
|
2
|
+
import { DBI } from "../DBI";
|
|
3
|
+
import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
|
|
4
|
+
import { IDBIToJSONArgs } from "../utils/UtilTypes";
|
|
5
|
+
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
6
|
+
import { DBIButtonBuilder, DBIButtonOverrides } from "./ButtonBuilder";
|
|
7
|
+
export interface IDBIButtonExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
|
|
8
|
+
interaction: Discord.ButtonInteraction<"cached">;
|
|
9
|
+
data: TDBIReferencedData[];
|
|
10
|
+
}
|
|
11
|
+
export declare type TDBIButtonOmitted<TNamespace extends NamespaceEnums> = Omit<DBIButton<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder">;
|
|
12
|
+
export declare class DBIButton<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
|
|
13
|
+
constructor(dbi: DBI<TNamespace>, args: TDBIButtonOmitted<TNamespace>);
|
|
14
|
+
options?: Omit<Discord.ButtonComponentData, "customId" | "type">;
|
|
15
|
+
onExecute(ctx: IDBIButtonExecuteCtx<TNamespace>): Promise<void> | void;
|
|
16
|
+
toJSON(arg?: IDBIToJSONArgs<DBIButtonOverrides>): Discord.ButtonComponentData;
|
|
17
|
+
createBuilder(arg?: IDBIToJSONArgs<DBIButtonOverrides>): DBIButtonBuilder<TNamespace>;
|
|
18
|
+
}
|
|
17
19
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -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,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,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;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,WAAW,oBAAoB,CAAC,UAAU,SAAS,cAAc,CAAE,SAAQ,kBAAkB,CAAC,UAAU,CAAC;IAC7G,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,iBAAiB,CAAC,UAAU,SAAS,cAAc,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,eAAe,CAAC,CAAC;AAE5J,qBAAa,SAAS,CAAC,UAAU,SAAS,cAAc,CAAE,SAAQ,kBAAkB,CAAC,UAAU,CAAC;gBAClF,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,UAAU,CAAC;IAO7D,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAC/E,MAAM,CAAC,GAAG,GAAE,cAAc,CAAC,kBAAkB,CAAM,GAAG,OAAO,CAAC,mBAAmB;IAOjF,aAAa,CAAC,GAAG,GAAE,cAAc,CAAC,kBAAkB,CAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC;CAI1F"}
|
package/dist/types/Button.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DBIButton = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const discord_js_1 = tslib_1.__importDefault(require("discord.js"));
|
|
6
|
-
const Interaction_1 = require("./Interaction");
|
|
7
|
-
const customId_1 = require("../utils/customId");
|
|
8
|
-
const stuffs_1 = tslib_1.__importDefault(require("stuffs"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DBIButton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const discord_js_1 = tslib_1.__importDefault(require("discord.js"));
|
|
6
|
+
const Interaction_1 = require("./Interaction");
|
|
7
|
+
const customId_1 = require("../utils/customId");
|
|
8
|
+
const stuffs_1 = tslib_1.__importDefault(require("stuffs"));
|
|
9
|
+
const ButtonBuilder_1 = require("./ButtonBuilder");
|
|
10
|
+
class DBIButton extends Interaction_1.DBIBaseInteraction {
|
|
11
|
+
constructor(dbi, args) {
|
|
12
|
+
super(dbi, {
|
|
13
|
+
...args,
|
|
14
|
+
type: "Button",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
onExecute(ctx) { }
|
|
18
|
+
;
|
|
19
|
+
toJSON(arg = {}) {
|
|
20
|
+
return {
|
|
21
|
+
...stuffs_1.default.defaultify((arg?.overrides || {}), this.options || {}, true),
|
|
22
|
+
customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
|
|
23
|
+
type: discord_js_1.default.ComponentType.Button,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
;
|
|
27
|
+
createBuilder(arg = {}) {
|
|
28
|
+
return new ButtonBuilder_1.DBIButtonBuilder({ component: this, ...arg });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DBIButton = DBIButton;
|
|
28
32
|
//# sourceMappingURL=Button.js.map
|
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,gDAAoD;AAGpD,4DAA4B;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;;AAAA,oEAAiC;AAEjC,+CAA2F;AAC3F,gDAAoD;AAGpD,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,0BAAe,EAAC,IAAI,CAAC,GAAU,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;YACtG,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 { customIdBuilder } 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: customIdBuilder(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}"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ButtonComponentData, ButtonStyle } from "discord.js";
|
|
2
|
+
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
3
|
+
import { DBIButton } from "./Button";
|
|
4
|
+
export declare type DBIButtonOverrides = {
|
|
5
|
+
style?: ButtonStyle;
|
|
6
|
+
} & Omit<ButtonComponentData, "customId" | "type" | "style">;
|
|
7
|
+
export declare class DBIButtonBuilder<TNamespace extends NamespaceEnums> {
|
|
8
|
+
component: DBIButton<TNamespace>;
|
|
9
|
+
overrides: DBIButtonOverrides;
|
|
10
|
+
reference: {
|
|
11
|
+
data: (string | number | object)[];
|
|
12
|
+
ttl?: number;
|
|
13
|
+
};
|
|
14
|
+
constructor(arg: {
|
|
15
|
+
component: DBIButton<TNamespace>;
|
|
16
|
+
overrides?: DBIButtonOverrides;
|
|
17
|
+
reference?: {
|
|
18
|
+
data: (string | number | object)[];
|
|
19
|
+
ttl?: number;
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
setTTL(ttl: number): DBIButtonBuilder<TNamespace>;
|
|
23
|
+
addTTL(ttl: number): DBIButtonBuilder<TNamespace>;
|
|
24
|
+
setData(...data: (string | number | object)[]): DBIButtonBuilder<TNamespace>;
|
|
25
|
+
addData(...data: (string | number | object)[]): DBIButtonBuilder<TNamespace>;
|
|
26
|
+
setOverrides(overrides: DBIButtonOverrides): DBIButtonBuilder<TNamespace>;
|
|
27
|
+
addOverrides(overrides: DBIButtonOverrides): DBIButtonBuilder<TNamespace>;
|
|
28
|
+
toJSON(): ButtonComponentData;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ButtonBuilder.d.ts.map
|