@mostfeatured/dbi 0.0.74-dev.0 → 0.0.74-dev.2
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/data/eventMap.json
CHANGED
|
@@ -180,7 +180,7 @@ function localeifyOptions(options, localeData) {
|
|
|
180
180
|
name_localizations: optionData.nameLocales,
|
|
181
181
|
description_localizations: optionData.descriptionLocales,
|
|
182
182
|
choices: i.choices ? i.choices.map((j) => {
|
|
183
|
-
let choiceLocale = optionData.choiceLocales[j.name];
|
|
183
|
+
let choiceLocale = optionData.choiceLocales[j.value ?? j.name];
|
|
184
184
|
return choiceLocale ? Object.assign(j, {
|
|
185
185
|
name_localizations: choiceLocale
|
|
186
186
|
}) : j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAOzD,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,OAAwC,EACxC,YAAsE,EACtE,mBAAqE,EACrE,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,M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CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAAE,EAAE;oBACrF,IAAI,CAAC,YAAY,CAAC,aAAa;wBAAE,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;oBACjE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC;wBAAE,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;oBACzG,IAAI,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;oBAElE,YAAY,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;gBACxC,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACvD,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACvE,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;AAhDD,oCAgDC","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, DBIClientData } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { ApplicationRoleConnectionMetadataType, ApplicationRoleConnectionMetadata } from \"../types/ApplicationRoleConnectionMetadata\";\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 clients: DBIClientData<NamespaceEnums>[],\r\n interactions: Discord.Collection<string, DBIChatInput<NamespaceEnums>>,\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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =\r\n interactions.reduce((all, current) => {\r\n if (current.publish && !all[current.publish]) all[current.publish] = [];\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[current.publish].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[current.publish].find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.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 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[current.publish].push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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[current.publish].find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all[current.publish].push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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 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]);\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 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 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[current.publish].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[current.publish].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 }, {} as {[k: string]: any});\r\n \r\n\r\n for (let i = 0; i < clients.length; i++) {\r\n const client = clients[i];\r\n const rest = new REST({ version: \"10\" });\r\n rest.setToken(client.token);\r\n \r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body: body[client.namespace] || [] });\r\n break;\r\n }\r\n case \"Global\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body: body[client.namespace] || [] });\r\n break;\r\n }\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 let optionData = localeData[i.name];\r\n return optionData ? Object.assign(i, {\r\n name_localizations: optionData.nameLocales,\r\n description_localizations: optionData.descriptionLocales,\r\n choices: i.choices ? i.choices.map((j) => {\r\n let choiceLocale = optionData.choiceLocales[j.name];\r\n return choiceLocale ? Object.assign(j, {\r\n name_localizations: choiceLocale\r\n }) : j;\r\n }) : undefined\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 let optionLocale = optionsLocales[optionName];\r\n if (!optionLocale.nameLocales) optionLocale.nameLocales = {};\r\n if (!optionLocale.descriptionLocales) optionLocale.descriptionLocales = {};\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n\r\n Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n if (!optionLocale.choiceLocales[choiceOriginalName]) optionLocale.choiceLocales[choiceOriginalName] = {};\r\n let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];\r\n \r\n choiceLocale[longLocale] = choiceName;\r\n });\r\n\r\n optionLocale.nameLocales[longLocale] = optionData.name;\r\n optionLocale.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}"]}
|
|
1
|
+
{"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAOzD,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,OAAwC,EACxC,YAAsE,EACtE,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;IAC5E,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC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CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;oBAElE,YAAY,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;gBACxC,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACvD,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACvE,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;AAhDD,oCAgDC","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, DBIClientData } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { ApplicationRoleConnectionMetadataType, ApplicationRoleConnectionMetadata } from \"../types/ApplicationRoleConnectionMetadata\";\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 clients: DBIClientData<NamespaceEnums>[],\r\n interactions: Discord.Collection<string, DBIChatInput<NamespaceEnums>>,\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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\r\n\r\n let body: {[k: string]: RESTPutAPIApplicationCommandsJSONBody} =\r\n interactions.reduce((all, current) => {\r\n if (current.publish && !all[current.publish]) all[current.publish] = [];\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[current.publish].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[current.publish].find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.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 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[current.publish].push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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[current.publish].find(i => i.name == current.name.split(\" \")[0] && i.type == ApplicationCommandType.ChatInput);\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all[current.publish].push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\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 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]);\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 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 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[current.publish].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[current.publish].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 }, {} as {[k: string]: any});\r\n \r\n\r\n for (let i = 0; i < clients.length; i++) {\r\n const client = clients[i];\r\n const rest = new REST({ version: \"10\" });\r\n rest.setToken(client.token);\r\n \r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body: body[client.namespace] || [] });\r\n break;\r\n }\r\n case \"Global\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body: body[client.namespace] || [] });\r\n break;\r\n }\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 let optionData = localeData[i.name];\r\n return optionData ? Object.assign(i, {\r\n name_localizations: optionData.nameLocales,\r\n description_localizations: optionData.descriptionLocales,\r\n choices: i.choices ? i.choices.map((j) => {\r\n let choiceLocale = optionData.choiceLocales[j.value ?? j.name];\r\n return choiceLocale ? Object.assign(j, {\r\n name_localizations: choiceLocale\r\n }) : j;\r\n }) : undefined\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 let optionLocale = optionsLocales[optionName];\r\n if (!optionLocale.nameLocales) optionLocale.nameLocales = {};\r\n if (!optionLocale.descriptionLocales) optionLocale.descriptionLocales = {};\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n\r\n Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {\r\n if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};\r\n if (!optionLocale.choiceLocales[choiceOriginalName]) optionLocale.choiceLocales[choiceOriginalName] = {};\r\n let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];\r\n \r\n choiceLocale[longLocale] = choiceName;\r\n });\r\n\r\n optionLocale.nameLocales[longLocale] = optionData.name;\r\n optionLocale.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/package.json
CHANGED
package/src/data/eventMap.json
CHANGED
|
@@ -196,7 +196,7 @@ export function localeifyOptions(options: any[], localeData: any): any[] {
|
|
|
196
196
|
name_localizations: optionData.nameLocales,
|
|
197
197
|
description_localizations: optionData.descriptionLocales,
|
|
198
198
|
choices: i.choices ? i.choices.map((j) => {
|
|
199
|
-
let choiceLocale = optionData.choiceLocales[j.name];
|
|
199
|
+
let choiceLocale = optionData.choiceLocales[j.value ?? j.name];
|
|
200
200
|
return choiceLocale ? Object.assign(j, {
|
|
201
201
|
name_localizations: choiceLocale
|
|
202
202
|
}) : j;
|