@mostfeatured/dbi 0.0.74-dev.1 → 0.0.74-dev.3
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/methods/publishInteractions.js +1 -1
- package/dist/methods/publishInteractions.js.map +1 -1
- package/dist/types/SelectMenuBuilder.d.ts +1 -1
- package/dist/types/SelectMenuBuilder.d.ts.map +1 -1
- package/dist/types/SelectMenuBuilder.js.map +1 -1
- package/package.json +2 -2
- package/src/methods/publishInteractions.ts +1 -1
- package/src/types/SelectMenuBuilder.ts +2 -2
|
@@ -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,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AkB;oBAAE,YAAY,CAAC,kBAAkB,GAAG,EAAE,CAAC;gBAC3E,IAAI,CAAC,YAAY,CAAC,aAAa;oBAAE,YAAY,CAAC,aAAa,GAAG,EAAE,CAAC;gBAEjE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,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;IAC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AAY,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.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}"]}
|
|
@@ -4,7 +4,7 @@ import { DBISelectMenu } from "./SelectMenu";
|
|
|
4
4
|
export declare type DBISelectMenuOverrides = Omit<StringSelectMenuComponentData, "customId" | "type">;
|
|
5
5
|
export declare class DBISelectMenuBuilder<TNamespace extends NamespaceEnums> {
|
|
6
6
|
component: DBISelectMenu<TNamespace>;
|
|
7
|
-
overrides: DBISelectMenuOverrides
|
|
7
|
+
overrides: Partial<DBISelectMenuOverrides>;
|
|
8
8
|
reference: {
|
|
9
9
|
data: (string | number | object)[];
|
|
10
10
|
ttl?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenuBuilder.d.ts","sourceRoot":"","sources":["../../src/types/SelectMenuBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,oBAAY,sBAAsB,GAAI,IAAI,CAAC,6BAA6B,EAAE,UAAU,GAAG,MAAM,CAAC,CAAA;AAE9F,qBAAa,oBAAoB,CAAC,UAAU,SAAS,cAAc;IACjE,SAAS,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACpC,SAAS,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectMenuBuilder.d.ts","sourceRoot":"","sources":["../../src/types/SelectMenuBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,oBAAY,sBAA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":"","sources":["../../src/types/SelectMenuBuilder.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AAMpC,MAAa,oBAAoB;IAC/B,SAAS,CAA2B;IACpC,SAAS,
|
|
1
|
+
{"version":3,"file":"SelectMenuBuilder.js","sourceRoot":"","sources":["../../src/types/SelectMenuBuilder.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AAMpC,MAAa,oBAAoB;IAC/B,SAAS,CAA2B;IACpC,SAAS,CAAkC;IAC3C,SAAS,CAAuD;IAChE,YAAY,GAAmJ;QAC7J,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,IAAkC;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,IAAkC;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,SAAiC;QAC5C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,SAAiC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAA,mBAAU,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAgB,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAChG,CAAC;CAEF;AA5CD,oDA4CC","sourcesContent":["import { BaseSelectMenuComponentData, StringSelectMenuComponentData } from \"discord.js\";\r\nimport { defaultify } from \"stuffs\";\r\nimport { NamespaceEnums } from \"../../generated/namespaceData\";\r\nimport { DBISelectMenu } from \"./SelectMenu\";\r\n\r\nexport type DBISelectMenuOverrides = Omit<StringSelectMenuComponentData, \"customId\" | \"type\">\r\n\r\nexport class DBISelectMenuBuilder<TNamespace extends NamespaceEnums> {\r\n component: DBISelectMenu<TNamespace>\r\n overrides: Partial<DBISelectMenuOverrides>;\r\n reference: { data: (string | number | object)[], ttl?: number };\r\n constructor(arg: { component: DBISelectMenu<TNamespace>, overrides?: DBISelectMenuOverrides, reference?: { data: (string | number | object)[], ttl?: number } }) {\r\n this.component = arg.component;\r\n this.overrides = arg.overrides ?? {};\r\n this.reference = arg.reference ?? { data: [] };\r\n }\r\n\r\n setTTL(ttl: number): DBISelectMenuBuilder<TNamespace> {\r\n this.reference.ttl = ttl;\r\n return this;\r\n }\r\n\r\n addTTL(ttl: number): DBISelectMenuBuilder<TNamespace> {\r\n this.reference.ttl = (this.reference.ttl ?? 0) + ttl;\r\n return this;\r\n }\r\n\r\n setData(...data: (string | number | object)[]): DBISelectMenuBuilder<TNamespace> {\r\n this.reference.data = data;\r\n return this;\r\n }\r\n\r\n addData(...data: (string | number | object)[]): DBISelectMenuBuilder<TNamespace> {\r\n this.reference.data = [...this.reference.data, ...data];\r\n return this;\r\n }\r\n\r\n setOverrides(overrides: DBISelectMenuOverrides): DBISelectMenuBuilder<TNamespace> {\r\n this.overrides = overrides;\r\n return this;\r\n }\r\n\r\n addOverrides(overrides: DBISelectMenuOverrides): DBISelectMenuBuilder<TNamespace> {\r\n this.overrides = defaultify(overrides, this.overrides, true);\r\n return this;\r\n }\r\n\r\n toJSON(): BaseSelectMenuComponentData {\r\n return this.component.toJSON({ overrides: this.overrides as any, reference: this.reference });\r\n }\r\n\r\n}"]}
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"async-and-quick": "^1.0.2",
|
|
5
5
|
"discord-api-types": "^0.37.0",
|
|
6
6
|
"discord-hybrid-sharding": "github:meister03/discord-hybrid-sharding",
|
|
7
|
-
"discord.js": "^14.
|
|
7
|
+
"discord.js": "^14.11.1-dev.1683374650-8d5ce32.0",
|
|
8
8
|
"lodash": "^4.17.21",
|
|
9
9
|
"snakecase-keys": "^5.4.2",
|
|
10
10
|
"stuffs": "^0.1.21"
|
|
11
11
|
},
|
|
12
12
|
"name": "@mostfeatured/dbi",
|
|
13
|
-
"version": "0.0.74-dev.
|
|
13
|
+
"version": "0.0.74-dev.3",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"private": false,
|
|
@@ -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;
|
|
@@ -7,7 +7,7 @@ export type DBISelectMenuOverrides = Omit<StringSelectMenuComponentData, "custo
|
|
|
7
7
|
|
|
8
8
|
export class DBISelectMenuBuilder<TNamespace extends NamespaceEnums> {
|
|
9
9
|
component: DBISelectMenu<TNamespace>
|
|
10
|
-
overrides: DBISelectMenuOverrides
|
|
10
|
+
overrides: Partial<DBISelectMenuOverrides>;
|
|
11
11
|
reference: { data: (string | number | object)[], ttl?: number };
|
|
12
12
|
constructor(arg: { component: DBISelectMenu<TNamespace>, overrides?: DBISelectMenuOverrides, reference?: { data: (string | number | object)[], ttl?: number } }) {
|
|
13
13
|
this.component = arg.component;
|
|
@@ -46,7 +46,7 @@ export class DBISelectMenuBuilder<TNamespace extends NamespaceEnums> {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
toJSON(): BaseSelectMenuComponentData {
|
|
49
|
-
return this.component.toJSON({ overrides: this.overrides, reference: this.reference });
|
|
49
|
+
return this.component.toJSON({ overrides: this.overrides as any, reference: this.reference });
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
}
|