@mostfeatured/dbi 0.0.38 → 0.0.39

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.
@@ -205,7 +205,7 @@ function formatLocale(locale) {
205
205
  longAliases.forEach((longLocale) => {
206
206
  allNameLocales[longLocale] = localeData.name;
207
207
  descriptionLocales[longLocale] = localeData.description;
208
- Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {
208
+ Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
209
209
  if (!optionsLocales[optionName])
210
210
  optionsLocales[optionName] = {};
211
211
  let optionLocale = optionsLocales[optionName];
@@ -215,7 +215,7 @@ function formatLocale(locale) {
215
215
  optionLocale.descriptionLocales = {};
216
216
  if (!optionLocale.choiceLocales)
217
217
  optionLocale.choiceLocales = {};
218
- Object.entries(optionData.choices).forEach(([choiceOriginalName, choiceName]) => {
218
+ Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
219
219
  if (!optionLocale.choiceLocales)
220
220
  optionLocale.choiceLocales = {};
221
221
  if (!optionLocale.choiceLocales[choiceOriginalName])
@@ -1 +1 @@
1
- {"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AAKzD,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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BACzG,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 } 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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\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 == 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 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 == ApplicationCommandType.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]);\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 switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Global\": {\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 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;AAKzD,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,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,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 } 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 interactions = interactions.sort((a, b) => b.name.split(\" \").length - a.name.split(\" \").length);\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 == 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 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 == ApplicationCommandType.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]);\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 switch (publishType) {\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Global\": {\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 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,6 +1,7 @@
1
1
  import Discord from "discord.js";
2
2
  import { DBI } from "../DBI";
3
3
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
4
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
4
5
  export interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {
5
6
  interaction: Discord.ButtonInteraction<"cached">;
6
7
  data: TDBIReferencedData[];
@@ -8,9 +9,8 @@ export interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {
8
9
  export declare type TDBIButtonOmitted = Omit<DBIButton, "type" | "description" | "dbi" | "toJSON">;
9
10
  export declare class DBIButton extends DBIBaseInteraction {
10
11
  constructor(dbi: DBI, args: TDBIButtonOmitted);
11
- options?: Omit<Discord.ButtonComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, "customId" | "type">);
12
+ options?: Omit<Discord.ButtonComponentData, "customId" | "type">;
12
13
  onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any;
13
- referenceTTL?: number;
14
- toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData;
14
+ toJSON(arg?: IDBIToJSONArgs<Discord.ButtonComponentData>): Discord.ButtonComponentData;
15
15
  }
16
16
  //# 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;AAG3F,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,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,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AAM,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IACjE,MAAM,CAAC,GAAG,GAAE,cAAc,CAAC,OAAO,CAAC,mBAAmB,CAAa,GAAG,OAAO,CAAC,mBAAmB;CAOlG"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DBIButton = void 0;
4
- const tslib_1 = require("tslib");
5
- const discord_js_1 = tslib_1.__importDefault(require("discord.js"));
6
4
  const Interaction_1 = require("./Interaction");
7
5
  const customId_1 = require("../utils/customId");
8
6
  class DBIButton extends Interaction_1.DBIBaseInteraction {
@@ -11,15 +9,14 @@ class DBIButton extends Interaction_1.DBIBaseInteraction {
11
9
  ...args,
12
10
  type: "Button",
13
11
  });
14
- this.referenceTTL = args.referenceTTL;
15
12
  }
16
13
  onExecute(ctx) { }
17
14
  ;
18
- toJSON(...customData) {
15
+ toJSON(arg = {}) {
19
16
  return {
20
- ...(typeof this.options == "function" ? this.options(customData) : this.options),
21
- customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData, this.referenceTTL),
22
- type: discord_js_1.default.ComponentType.Button
17
+ ...this.options,
18
+ ...(arg?.override || {}),
19
+ customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
23
20
  };
24
21
  }
25
22
  ;
@@ -1 +1 @@
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;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACxC,CAAC;IAIQ,SAAS,CAAC,GAAyB,IAAwB,CAAC;IAAA,CAAC;IAEtE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAChF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;YAC7E,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,MAAM;SAC5B,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AApBD,8BAoBC","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<\"cached\">;\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 this.referenceTTL = args.referenceTTL;\r\n }\r\n\r\n declare options?: Omit<Discord.ButtonComponentData, \"customId\" | \"type\"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, \"customId\" | \"type\">);\r\n\r\n override onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any { };\r\n declare referenceTTL?: number\r\n toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL),\r\n type: Discord.ComponentType.Button\r\n } as any;\r\n };\r\n}"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/types/Button.ts"],"names":[],"mappings":";;;AAEA,+CAA2F;AAC3F,gDAAoD;AAUpD,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;IACtE,MAAM,CAAC,MAAmD,EAAS;QACjE,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SACzF,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAlBD,8BAkBC","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\n\r\nexport interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\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 toJSON(arg: IDBIToJSONArgs<Discord.ButtonComponentData> = {} as any): Discord.ButtonComponentData {\r\n return {\r\n ...this.options,\r\n ...(arg?.override || {}),\r\n customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)\r\n } as any;\r\n };\r\n}"]}
@@ -1,6 +1,7 @@
1
1
  import { DBI } from "../DBI";
2
2
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
3
3
  import Discord from "discord.js";
4
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
4
5
  export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
5
6
  interaction: Discord.ModalSubmitInteraction<"cached">;
6
7
  data: TDBIReferencedData[];
@@ -12,9 +13,8 @@ export interface ModalComponentData {
12
13
  export declare type TDBIModalOmitted = Omit<DBIModal, "type" | "description" | "dbi" | "toJSON">;
13
14
  export declare class DBIModal extends DBIBaseInteraction {
14
15
  constructor(dbi: DBI, args: TDBIModalOmitted);
15
- options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);
16
+ options: ModalComponentData;
16
17
  onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any;
17
- referenceTTL?: number;
18
- toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData;
18
+ toJSON(arg?: IDBIToJSONArgs<ModalComponentData>): Discord.ModalComponentData;
19
19
  }
20
20
  //# sourceMappingURL=Modal.d.ts.map
@@ -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,kBAAkB,E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AkB;IAC7D,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEtD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC;CAC5E;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,IAAI,EAAE,gBAAgB;IAOpC,OAAO,EAAE,kBAAkB,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAEhE,MAAM,CAAC,GAAG,GAAE,cAAc,CAAC,kBAAkB,CAAa,GAAG,OAAO,CAAC,kBAAkB;CAOxF"}
@@ -9,14 +9,14 @@ class DBIModal extends Interaction_1.DBIBaseInteraction {
9
9
  ...args,
10
10
  type: "Modal"
11
11
  });
12
- this.referenceTTL = args.referenceTTL;
13
12
  }
14
13
  onExecute(ctx) { }
15
14
  ;
16
- toJSON(...customData) {
15
+ toJSON(arg = {}) {
17
16
  return {
18
- ...(typeof this.options == "function" ? this.options(customData) : this.options),
19
- customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData, this.referenceTTL)
17
+ ...this.options,
18
+ ...(arg?.override || {}),
19
+ customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
20
20
  };
21
21
  }
22
22
  ;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAepD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,IAAsB;QAC1C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACxC,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAIrE,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YACvF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;SACvE,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AArBD,4BAqBC","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<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n this.referenceTTL = args.referenceTTL;\r\n }\r\n\r\n declare options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n declare referenceTTL?: number;\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData as any) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL)\r\n } as any;\r\n };\r\n}"]}
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/types/Modal.ts"],"names":[],"mappings":";;;AACA,+CAA2F;AAE3F,gDAAoD;AAgBpD,MAAa,QAAS,SAAQ,gCAAkB;IAC9C,YAAY,GAAQ,EAAE,IAAsB;QAC1C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,IAAY;YAChB,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;IAIQ,SAAS,CAAC,GAAwB,IAAwB,CAAC;IAAA,CAAC;IAErE,MAAM,CAAC,MAA0C,EAAS;QACxD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SACzF,CAAC;IACX,CAAC;IAAA,CAAC;CACH;AAnBD,4BAmBC","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\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\n\r\nexport interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ModalSubmitInteraction<\"cached\">;\r\n\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport interface ModalComponentData {\r\n title: string;\r\n components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];\r\n}\r\n\r\nexport type TDBIModalOmitted = Omit<DBIModal, \"type\" | \"description\" | \"dbi\" | \"toJSON\">;\r\n\r\nexport class DBIModal extends DBIBaseInteraction {\r\n constructor(dbi: DBI, args: TDBIModalOmitted) {\r\n super(dbi, {\r\n ...(args as any),\r\n type: \"Modal\"\r\n });\r\n }\r\n\r\n declare options: ModalComponentData;\r\n\r\n override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };\r\n\r\n toJSON(arg: IDBIToJSONArgs<ModalComponentData> = {} as any): Discord.ModalComponentData {\r\n return {\r\n ...this.options,\r\n ...(arg?.override || {}),\r\n customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)\r\n } as any;\r\n };\r\n}"]}
@@ -1,6 +1,7 @@
1
1
  import Discord from "discord.js";
2
2
  import { DBI } from "../DBI";
3
3
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
4
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
4
5
  export interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {
5
6
  interaction: Discord.ButtonInteraction<"cached">;
6
7
  data: TDBIReferencedData[];
@@ -8,9 +9,8 @@ export interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {
8
9
  export declare type TDBISelectMenuOmitted = Omit<DBISelectMenu, "type" | "description" | "dbi" | "toJSON">;
9
10
  export declare class DBISelectMenu extends DBIBaseInteraction {
10
11
  constructor(dbi: DBI, args: TDBISelectMenuOmitted);
11
- options: Omit<Discord.SelectMenuComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, "customId" | "type">);
12
+ options: Omit<Discord.SelectMenuComponentData, "customId" | "type">;
12
13
  onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any;
13
- referenceTTL?: number;
14
- toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData;
14
+ toJSON(arg?: IDBIToJSONArgs<Discord.SelectMenuComponentData>): Discord.SelectMenuComponentData;
15
15
  }
16
16
  //# sourceMappingURL=SelectMenu.d.ts.map
@@ -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,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3F,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEnG,qBAAa,aAAc,SAAQ,kBAAkB;gBACvC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB;IAQzC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC;IAEvK,SAAS,CAAC,GAAG,EAAE,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAE7D,YAAY,CAAC,EAAE,MAAM,CAAC;IAE9B,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,uBAAuB;CAOrF"}
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;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,oBAAY,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEnG,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,GAAE,cAAc,CAAC,OAAO,CAAC,uBAAuB,CAAa,GAAG,OAAO,CAAC,uBAAuB;CAO1G"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DBISelectMenu = void 0;
4
- const tslib_1 = require("tslib");
5
- const discord_js_1 = tslib_1.__importDefault(require("discord.js"));
6
4
  const Interaction_1 = require("./Interaction");
7
5
  const customId_1 = require("../utils/customId");
8
6
  class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
@@ -11,15 +9,14 @@ class DBISelectMenu extends Interaction_1.DBIBaseInteraction {
11
9
  ...args,
12
10
  type: "SelectMenu",
13
11
  });
14
- this.referenceTTL = args.referenceTTL;
15
12
  }
16
13
  onExecute(ctx) { }
17
14
  ;
18
- toJSON(...customData) {
15
+ toJSON(arg = {}) {
19
16
  return {
20
- ...(typeof this.options == "function" ? this.options(customData) : this.options),
21
- customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, customData, this.referenceTTL),
22
- type: discord_js_1.default.ComponentType.SelectMenu
17
+ ...this.options,
18
+ ...(arg?.override || {}),
19
+ customId: (0, customId_1.customIdBuilder)(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
23
20
  };
24
21
  }
25
22
  ;
@@ -1 +1 @@
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;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACxC,CAAC;IAIQ,SAAS,CAAC,GAA6B,IAAwB,CAAC;IAAA,CAAC;IAI1E,MAAM,CAAC,GAAG,UAAwC;QAChD,OAAO;YACL,GAAG,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAChF,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;YAC7E,IAAI,EAAE,oBAAO,CAAC,aAAa,CAAC,UAAU;SAChC,CAAA;IACV,CAAC;IAAA,CAAC;CACH;AAtBD,sCAsBC","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<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted = Omit<DBISelectMenu, \"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 this.referenceTTL = args.referenceTTL;\r\n }\r\n\r\n declare options: Omit<Discord.SelectMenuComponentData, \"customId\" | \"type\"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, \"customId\" | \"type\">);\r\n\r\n override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };\r\n\r\n declare referenceTTL?: number;\r\n\r\n toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {\r\n return {\r\n ...(typeof this.options == \"function\" ? this.options(customData) : this.options),\r\n customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL),\r\n type: Discord.ComponentType.SelectMenu\r\n } as any\r\n };\r\n}"]}
1
+ {"version":3,"file":"SelectMenu.js","sourceRoot":"","sources":["../../src/types/SelectMenu.ts"],"names":[],"mappings":";;;AAEA,+CAA2F;AAC3F,gDAAoD;AAUpD,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,MAAuD,EAAS;QACrE,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;YACxB,QAAQ,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC;SACzF,CAAC;IACX,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\nimport { IDBIToJSONArgs } from \"../utils/UtilTypes\";\r\n\r\nexport interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ButtonInteraction<\"cached\">;\r\n data: TDBIReferencedData[];\r\n}\r\n\r\nexport type TDBISelectMenuOmitted = Omit<DBISelectMenu, \"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(arg: IDBIToJSONArgs<Discord.SelectMenuComponentData> = {} as any): Discord.SelectMenuComponentData {\r\n return {\r\n ...this.options,\r\n ...(arg?.override || {}),\r\n customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)\r\n } as any;\r\n };\r\n}"]}
@@ -0,0 +1,8 @@
1
+ export interface IDBIToJSONArgs<T> {
2
+ reference?: {
3
+ tll?: number;
4
+ data: (string | number | object)[];
5
+ };
6
+ override: T;
7
+ }
8
+ //# sourceMappingURL=UtilTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UtilTypes.d.ts","sourceRoot":"","sources":["../../src/utils/UtilTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE;QACV,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;KACpC,CAAC;IACF,QAAQ,EAAE,CAAC,CAAC;CACb"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=UtilTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UtilTypes.js","sourceRoot":"","sources":["../../src/utils/UtilTypes.ts"],"names":[],"mappings":"","sourcesContent":["export interface IDBIToJSONArgs<T> {\r\n reference?: {\r\n tll?: number;\r\n data: (string | number | object)[];\r\n };\r\n override: T;\r\n}"]}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "stuffs": "^0.1.17"
10
10
  },
11
11
  "name": "@mostfeatured/dbi",
12
- "version": "0.0.38",
12
+ "version": "0.0.39",
13
13
  "main": "dist/index.js",
14
14
  "type": "commonjs",
15
15
  "private": false,
@@ -221,14 +221,14 @@ export function formatLocale(locale: DBIInteractionLocale): any {
221
221
  longAliases.forEach((longLocale) => {
222
222
  allNameLocales[longLocale] = localeData.name;
223
223
  descriptionLocales[longLocale] = localeData.description;
224
- Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {
224
+ Object.entries(localeData?.options || {}).forEach(([optionName, optionData]) => {
225
225
  if (!optionsLocales[optionName]) optionsLocales[optionName] = {};
226
226
  let optionLocale = optionsLocales[optionName];
227
227
  if (!optionLocale.nameLocales) optionLocale.nameLocales = {};
228
228
  if (!optionLocale.descriptionLocales) optionLocale.descriptionLocales = {};
229
229
  if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};
230
230
 
231
- Object.entries(optionData.choices).forEach(([choiceOriginalName, choiceName]) => {
231
+ Object.entries(optionData?.choices || {}).forEach(([choiceOriginalName, choiceName]) => {
232
232
  if (!optionLocale.choiceLocales) optionLocale.choiceLocales = {};
233
233
  if (!optionLocale.choiceLocales[choiceOriginalName]) optionLocale.choiceLocales[choiceOriginalName] = {};
234
234
  let choiceLocale = optionLocale.choiceLocales[choiceOriginalName];
@@ -2,6 +2,7 @@ import Discord from "discord.js";
2
2
  import { DBI } from "../DBI";
3
3
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
4
4
  import { customIdBuilder } from "../utils/customId";
5
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
5
6
 
6
7
  export interface IDBIButtonExecuteCtx extends IDBIBaseExecuteCtx {
7
8
  interaction: Discord.ButtonInteraction<"cached">;
@@ -16,18 +17,16 @@ export class DBIButton extends DBIBaseInteraction {
16
17
  ...(args as any),
17
18
  type: "Button",
18
19
  });
19
- this.referenceTTL = args.referenceTTL;
20
20
  }
21
21
 
22
- declare options?: Omit<Discord.ButtonComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.ButtonComponentData, "customId" | "type">);
22
+ declare options?: Omit<Discord.ButtonComponentData, "customId" | "type">;
23
23
 
24
24
  override onExecute(ctx: IDBIButtonExecuteCtx): Promise<any> | any { };
25
- declare referenceTTL?: number
26
- toJSON(...customData: (string | number | object)[]): Discord.ButtonComponentData {
25
+ toJSON(arg: IDBIToJSONArgs<Discord.ButtonComponentData> = {} as any): Discord.ButtonComponentData {
27
26
  return {
28
- ...(typeof this.options == "function" ? this.options(customData) : this.options),
29
- customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL),
30
- type: Discord.ComponentType.Button
27
+ ...this.options,
28
+ ...(arg?.override || {}),
29
+ customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
31
30
  } as any;
32
31
  };
33
32
  }
@@ -2,6 +2,7 @@ import { DBI } from "../DBI";
2
2
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
3
3
  import Discord from "discord.js";
4
4
  import { customIdBuilder } from "../utils/customId";
5
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
5
6
 
6
7
  export interface IDBIModalExecuteCtx extends IDBIBaseExecuteCtx {
7
8
  interaction: Discord.ModalSubmitInteraction<"cached">;
@@ -22,19 +23,17 @@ export class DBIModal extends DBIBaseInteraction {
22
23
  ...(args as any),
23
24
  type: "Modal"
24
25
  });
25
- this.referenceTTL = args.referenceTTL;
26
26
  }
27
27
 
28
- declare options: ModalComponentData | ((data: TDBIReferencedData[]) => ModalComponentData);
28
+ declare options: ModalComponentData;
29
29
 
30
30
  override onExecute(ctx: IDBIModalExecuteCtx): Promise<any> | any { };
31
31
 
32
- declare referenceTTL?: number;
33
-
34
- toJSON(...customData: (string | number | object)[]): Discord.ModalComponentData {
32
+ toJSON(arg: IDBIToJSONArgs<ModalComponentData> = {} as any): Discord.ModalComponentData {
35
33
  return {
36
- ...(typeof this.options == "function" ? this.options(customData as any) : this.options),
37
- customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL)
34
+ ...this.options,
35
+ ...(arg?.override || {}),
36
+ customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
38
37
  } as any;
39
38
  };
40
39
  }
@@ -2,6 +2,7 @@ import Discord from "discord.js";
2
2
  import { DBI } from "../DBI";
3
3
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "./Interaction";
4
4
  import { customIdBuilder } from "../utils/customId";
5
+ import { IDBIToJSONArgs } from "../utils/UtilTypes";
5
6
 
6
7
  export interface IDBISelectMenuExecuteCtx extends IDBIBaseExecuteCtx {
7
8
  interaction: Discord.ButtonInteraction<"cached">;
@@ -16,20 +17,17 @@ export class DBISelectMenu extends DBIBaseInteraction {
16
17
  ...(args as any),
17
18
  type: "SelectMenu",
18
19
  });
19
- this.referenceTTL = args.referenceTTL;
20
20
  }
21
21
 
22
- declare options: Omit<Discord.SelectMenuComponentData, "customId" | "type"> | ((data: (number | string | any)[]) => Omit<Discord.SelectMenuComponentData, "customId" | "type">);
22
+ declare options: Omit<Discord.SelectMenuComponentData, "customId" | "type">;
23
23
 
24
24
  override onExecute(ctx: IDBISelectMenuExecuteCtx): Promise<any> | any { };
25
25
 
26
- declare referenceTTL?: number;
27
-
28
- toJSON(...customData: (string | number | object)[]): Discord.SelectMenuComponentData {
26
+ toJSON(arg: IDBIToJSONArgs<Discord.SelectMenuComponentData> = {} as any): Discord.SelectMenuComponentData {
29
27
  return {
30
- ...(typeof this.options == "function" ? this.options(customData) : this.options),
31
- customId: customIdBuilder(this.dbi, this.name, customData, this.referenceTTL),
32
- type: Discord.ComponentType.SelectMenu
33
- } as any
28
+ ...this.options,
29
+ ...(arg?.override || {}),
30
+ customId: customIdBuilder(this.dbi, this.name, arg?.reference?.data || [], arg?.reference?.tll)
31
+ } as any;
34
32
  };
35
33
  }
@@ -0,0 +1,7 @@
1
+ export interface IDBIToJSONArgs<T> {
2
+ reference?: {
3
+ tll?: number;
4
+ data: (string | number | object)[];
5
+ };
6
+ override: T;
7
+ }