@mostfeatured/dbi 0.0.10 → 0.0.13

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.
Files changed (40) hide show
  1. package/dist/DBI.d.ts +42 -5
  2. package/dist/DBI.d.ts.map +1 -1
  3. package/dist/DBI.js +44 -2
  4. package/dist/DBI.js.map +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/methods/hookInteractionListeners.js +2 -2
  9. package/dist/methods/hookInteractionListeners.js.map +1 -1
  10. package/dist/methods/publishInteractions.d.ts +4 -1
  11. package/dist/methods/publishInteractions.d.ts.map +1 -1
  12. package/dist/methods/publishInteractions.js +83 -10
  13. package/dist/methods/publishInteractions.js.map +1 -1
  14. package/dist/types/ChatInput/ChatInput.d.ts.map +1 -1
  15. package/dist/types/ChatInput/ChatInput.js +2 -0
  16. package/dist/types/ChatInput/ChatInput.js.map +1 -1
  17. package/dist/types/InteractionLocale.d.ts +22 -0
  18. package/dist/types/InteractionLocale.d.ts.map +1 -0
  19. package/dist/types/InteractionLocale.js +15 -0
  20. package/dist/types/InteractionLocale.js.map +1 -0
  21. package/dist/types/MessageContextMenu.d.ts.map +1 -1
  22. package/dist/types/MessageContextMenu.js +2 -0
  23. package/dist/types/MessageContextMenu.js.map +1 -1
  24. package/dist/types/UserContextMenu.d.ts.map +1 -1
  25. package/dist/types/UserContextMenu.js +2 -0
  26. package/dist/types/UserContextMenu.js.map +1 -1
  27. package/dist/utils/MemoryStore.d.ts +1 -1
  28. package/dist/utils/MemoryStore.d.ts.map +1 -1
  29. package/dist/utils/MemoryStore.js +1 -1
  30. package/dist/utils/MemoryStore.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/DBI.ts +73 -8
  33. package/src/index.ts +3 -3
  34. package/src/methods/hookInteractionListeners.ts +2 -2
  35. package/src/methods/publishInteractions.ts +85 -8
  36. package/src/types/ChatInput/ChatInput.ts +3 -0
  37. package/src/types/InteractionLocale.ts +28 -0
  38. package/src/types/MessageContextMenu.ts +3 -0
  39. package/src/types/UserContextMenu.ts +3 -0
  40. package/src/utils/MemoryStore.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AACzD,4EAA2C;AAE3C,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AAE1E,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,YAAsD,EACtD,WAA+B,EAC/B,OAAgB;IAEhB,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5E,MAAM,IAAI,GAAG,IAAI,WAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE3B,MAAM,EAAE,GAAyB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAM,CAAC,IAAI,EAAE,CAAQ,CAAC;IAEtE,MAAM,IAAI,GACR,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QACnC,QAAQ,OAAO,CAAC,IAAI,EAAE;YACpB,KAAK,WAAW,CAAC,CAAC;gBAChB,IAAI,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC3C,QAAQ,YAAY,CAAC,MAAM,EAAE;oBAC3B,KAAK,CAAC,CAAC,CAAC;wBACN,GAAG,CAAC,IAAI,CAAC;4BACP,IAAI,EAAE,2BAAsB,CAAC,SAAS;4BACtC,WAAW,EAAE,OAAO,CAAC,WAAW;4BAChC,IAAI,E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BAAiB,CAAC,CAAC;gBACtB,GAAG,CAAC,IAAI,CAAC;oBACP,IAAI,EAAE,2BAAsB,CAAC,IAAI;oBACjC,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,0BAA0B,EAAE,IAAA,+BAAiB,EAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE;oBAC1F,aAAa,EAAE,OAAO,CAAC,cAAc;iBACtC,CAAC,CAAC;gBACH,MAAM;aACP;SACF;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAGT,QAAQ,WAAW,EAAE;QACnB,KAAK,QAAQ,CAAC,CAAC;YACb,MAAM,IAAI,CAAC,GAAG,CAAC,WAAM,CAAC,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,MAAM;SACP;QACD,KAAK,OAAO,CAAC,CAAC;YACZ,MAAM,IAAI,CAAC,GAAG,CAAC,WAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5D,MAAM;SACP;KACF;AAEH,CAAC;AApJD,kDAoJC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n const body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1] && i.type == \"ChatInput\");\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: snakecaseKeys(current.options || [])\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}"]}
1
+ {"version":3,"file":"publishInteractions.js","sourceRoot":"","sources":["../../src/methods/publishInteractions.ts"],"names":[],"mappings":";;;;AAEA,0CAAuC;AACvC,6CAAiK;AACjK,sDAAyD;AACzD,4EA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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC;QAClF,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;YAC7C,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACxD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE;gBAC5E,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;oBAAE,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;gBACjE,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW;oBAAE,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC;gBACzF,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB;oBAAE,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB,GAAG,EAAE,CAAC;gBAEvG,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;gBACrE,cAAc,CAAC,UAAU,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;YACrF,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,cAAc;KACf,CAAA;AACH,CAAC;AAtCD,oCAsCC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBIChatInput } from \"../types/ChatInput/ChatInput\";\r\nimport { REST } from \"@discordjs/rest\";\r\nimport { Routes, RESTGetAPIUserResult, RESTPutAPIApplicationCommandsJSONBody, ApplicationCommandType, ApplicationCommandOptionType } from \"discord-api-types/v9\";\r\nimport { reducePermissions } from \"../utils/permissions\";\r\nimport snakecaseKeys from \"snakecase-keys\";\r\nimport { DBI } from \"../DBI\";\r\nimport { DBIInteractionLocale } from \"../types/InteractionLocale\";\r\n\r\nconst PUBLISHABLE_TYPES = [\"ChatInput\", \"UserContextMenu\", \"MessageContextMenu\"];\r\nconst ORIGINAL_LOCALES = [\"da\", \"de\", \"en-GB\", \"en-US\", \"es-ES\", \"fr\", \"hr\", \"it\", \"lt\", \"hu\", \"nl\", \"no\", \"pl\", \"pt-BR\", \"ro\", \"fi\", \"sv-SE\", \"vi\", \"tr\", \"cs\", \"el\", \"bg\", \"ru\", \"uk\", \"hi\", \"th\", \"zh-CN\", \"ja\", \"zh-TW\", \"ko\"];\r\n\r\nexport async function publishInteractions(\r\n clientToken: string,\r\n interactions: Discord.Collection<string, DBIChatInput>,\r\n interactionsLocales: Discord.Collection<string, DBIInteractionLocale>,\r\n publishType: \"Guild\" | \"Global\",\r\n guildId?: string\r\n) {\r\n interactions = interactions.filter(i => PUBLISHABLE_TYPES.includes(i.type));\r\n\r\n const rest = new REST({ version: \"9\" });\r\n rest.setToken(clientToken);\r\n\r\n const me: RESTGetAPIUserResult = await rest.get(Routes.user()) as any;\r\n \r\n let body: RESTPutAPIApplicationCommandsJSONBody =\r\n interactions.reduce((all, current) => {\r\n switch (current.type) {\r\n case \"ChatInput\": {\r\n let nameSplitted = current.name.split(\" \");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n switch (nameSplitted.length) {\r\n case 1: {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n description: current.description,\r\n name: nameSplitted[0],\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(0),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case 2: {\r\n let baseItem = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n let option = {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[1],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(1),\r\n description_localizations: localeData.descriptionLocales,\r\n };\r\n if (!baseItem) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n option\r\n ]\r\n });\r\n } else {\r\n baseItem.options.push(option);\r\n }\r\n break;\r\n }\r\n case 3: {\r\n let level1Item = all.find(i => i.name == current.name.split(\" \")[0] && i.type == \"ChatInput\");\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n if (!level1Item) {\r\n all.push({\r\n type: ApplicationCommandType.ChatInput,\r\n name: nameSplitted[0],\r\n name_localizations: localeData.nameLocales(0),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n } else {\r\n let level2Item = level1Item.options.find(i => i.name == current.name.split(\" \")[1] && i.type == \"ChatInput\");\r\n if (!level2Item) {\r\n level1Item.options.push({\r\n type: ApplicationCommandOptionType.SubcommandGroup,\r\n name: nameSplitted[1],\r\n name_localizations: localeData.nameLocales(1),\r\n description: \"...\",\r\n options: [\r\n {\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales\r\n }\r\n ]\r\n })\r\n } else {\r\n level2Item.options.push({\r\n type: ApplicationCommandOptionType.Subcommand,\r\n name: nameSplitted[2],\r\n description: current.description,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n options: localeifyOptions(current.options || [], localeData.optionsLocales),\r\n name_localizations: localeData.nameLocales(2),\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n case \"MessageContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.Message,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales,\r\n });\r\n break;\r\n }\r\n case \"UserContextMenu\": {\r\n let localeData = formatLocale(interactionsLocales.get(current.name) ?? {} as any);\r\n all.push({\r\n type: ApplicationCommandType.User,\r\n name: current.name,\r\n default_member_permissions: reducePermissions(current.defaultMemberPermissions).toString(),\r\n dm_permission: current.directMessages,\r\n name_localizations: localeData.allNameLocales,\r\n description_localizations: localeData.descriptionLocales\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return all;\r\n }, []);\r\n \r\n body = snakecaseKeys(body);\r\n \r\n switch (publishType) {\r\n case \"Global\": {\r\n await rest.put(Routes.applicationGuildCommands(me.id, guildId), { body });\r\n break;\r\n }\r\n case \"Guild\": {\r\n await rest.put(Routes.applicationCommands(me.id), { body });\r\n break;\r\n }\r\n }\r\n \r\n}\r\n\r\nexport function localeifyOptions(options: any[], localeData: any): any[] {\r\n return options.map(i => {\r\n return localeData[i.name] ? Object.assign(i, {\r\n name_localizations: localeData[i.name].nameLocales,\r\n description_localizations: localeData[i.name].descriptionLocales,\r\n }) : i;\r\n })\r\n}\r\n\r\nexport function formatLocale(locale: DBIInteractionLocale): any {\r\n let allNameLocales = {};\r\n let descriptionLocales = {};\r\n let optionsLocales = {};\r\n\r\n function nameLocales(index) {\r\n return Object.fromEntries(Object.entries(allNameLocales).map(i => [i[0], (i[1] as string).split(\" \").at(index)]));\r\n }\r\n\r\n if (!locale?.data) return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n };\r\n\r\n Object.entries(locale.data).forEach(([shortLocale, localeData]) => {\r\n let longAliases = ORIGINAL_LOCALES.filter(i => i.split(\"-\").at(0) == shortLocale);\r\n longAliases.forEach((longLocale) => {\r\n allNameLocales[longLocale] = localeData.name;\r\n descriptionLocales[longLocale] = localeData.description;\r\n Object.entries(localeData.options || []).forEach(([optionName, optionData]) => {\r\n if (!optionsLocales[optionName]) optionsLocales[optionName] = {};\r\n if (!optionsLocales[optionName].nameLocales) optionsLocales[optionName].nameLocales = {};\r\n if (!optionsLocales[optionName].descriptionLocales) optionsLocales[optionName].descriptionLocales = {};\r\n\r\n optionsLocales[optionName].nameLocales[longLocale] = optionData.name;\r\n optionsLocales[optionName].descriptionLocales[longLocale] = optionData.description;\r\n })\r\n });\r\n });\r\n \r\n return {\r\n nameLocales,\r\n allNameLocales,\r\n descriptionLocales,\r\n optionsLocales\r\n }\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInput.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE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,EAAE,CAAC;IACf,SAAS,CAAC,GAAG,EAAE,uBAAuB;CAChD"}
@@ -10,6 +10,8 @@ class DBIChatInput extends Interaction_1.DBIBaseInteraction {
10
10
  name: cfg.name.toLowerCase(),
11
11
  options: Array.isArray(cfg.options) ? cfg.options : []
12
12
  });
13
+ this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;
14
+ this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;
13
15
  }
14
16
  directMessages;
15
17
  defaultMemberPermissions;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.js","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInput.ts"],"names":[],"mappings":";;;AAEA,gDAAwE;AAQxE,MAAa,YAAa,SAAQ,gCAAkB;IAClD,YAAY,GAAQ,EAAE,GAAyB;QAC7C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;SACvD,CAAC,CAAC;IACL,CAAC;IACD,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAE9C,SAAS,CAAC,GAA4B,IAAG,CAAC;CACpD;AAbD,oCAaC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"../Interaction\";\r\n\r\nexport interface IDBIChatInputExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ChatInputCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\nexport type TDBIChatInputOmitted = Omit<DBIChatInput, \"type\" | \"dbi\">;\r\n\r\nexport class DBIChatInput extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIChatInputOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"ChatInput\",\r\n name: cfg.name.toLowerCase(),\r\n options: Array.isArray(cfg.options) ? cfg.options : []\r\n });\r\n }\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n declare options?: any[];\r\n override onExecute(ctx: IDBIChatInputExecuteCtx) {}\r\n}"]}
1
+ {"version":3,"file":"ChatInput.js","sourceRoot":"","sources":["../../../src/types/ChatInput/ChatInput.ts"],"names":[],"mappings":";;;AAEA,gDAAwE;AAQxE,MAAa,YAAa,SAAQ,gCAAkB;IAClD,YAAY,GAAQ,EAAE,GAAyB;QAC7C,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;SACvD,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/E,IAAI,CAAC,wBAAwB,GAAG,GAAG,CAAC,wBAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC/G,CAAC;IACD,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAE9C,SAAS,CAAC,GAA4B,IAAG,CAAC;CACpD;AAhBD,oCAgBC","sourcesContent":["import Discord from \"discord.js\";\r\nimport { DBI } from \"../../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"../Interaction\";\r\n\r\nexport interface IDBIChatInputExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.ChatInputCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\nexport type TDBIChatInputOmitted = Omit<DBIChatInput, \"type\" | \"dbi\">;\r\n\r\nexport class DBIChatInput extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIChatInputOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"ChatInput\",\r\n name: cfg.name.toLowerCase(),\r\n options: Array.isArray(cfg.options) ? cfg.options : []\r\n });\r\n\r\n this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;\r\n this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;\r\n }\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n declare options?: any[];\r\n override onExecute(ctx: IDBIChatInputExecuteCtx) {}\r\n}"]}
@@ -0,0 +1,22 @@
1
+ import { DBI } from "../DBI";
2
+ import { TDBILocaleString } from "./Locale";
3
+ export declare type TDBIInteractionLocaleData = {
4
+ [K in TDBILocaleString]?: {
5
+ name: string;
6
+ description: string;
7
+ options?: {
8
+ [k: string]: {
9
+ name: string;
10
+ description: string;
11
+ };
12
+ };
13
+ };
14
+ };
15
+ export declare type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, "dbi">;
16
+ export declare class DBIInteractionLocale {
17
+ name: string;
18
+ data: TDBIInteractionLocaleData;
19
+ dbi: DBI;
20
+ constructor(dbi: any, cfg: TDBIInteractionLocaleOmitted);
21
+ }
22
+ //# sourceMappingURL=InteractionLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionLocale.d.ts","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,yBAAyB,GAAG;KACrC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE;YACR,CAAC,CAAC,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;aACrB,CAAA;SACF,CAAA;KACF;CACF,CAAC;AAEF,oBAAY,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAE7E,qBAAa,oBAAoB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,yBAAyB,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;gBACG,GAAG,KAAA,EAAE,GAAG,EAAE,4BAA4B;CAKnD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DBIInteractionLocale = void 0;
4
+ class DBIInteractionLocale {
5
+ name;
6
+ data;
7
+ dbi;
8
+ constructor(dbi, cfg) {
9
+ this.dbi = dbi;
10
+ this.name = cfg.name;
11
+ this.data = cfg.data;
12
+ }
13
+ }
14
+ exports.DBIInteractionLocale = DBIInteractionLocale;
15
+ //# sourceMappingURL=InteractionLocale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionLocale.js","sourceRoot":"","sources":["../../src/types/InteractionLocale.ts"],"names":[],"mappings":";;;AAkBA,MAAa,oBAAoB;IAC/B,IAAI,CAAS;IACb,IAAI,CAA4B;IAChC,GAAG,CAAM;IACT,YAAY,GAAG,EAAE,GAAiC;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AATD,oDASC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { TDBILocaleString } from \"./Locale\";\r\n\r\nexport type TDBIInteractionLocaleData = {\r\n [K in TDBILocaleString]?: {\r\n name: string;\r\n description: string;\r\n options?: {\r\n [k: string]: {\r\n name: string;\r\n description: string;\r\n }\r\n }\r\n };\r\n};\r\n\r\nexport type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, \"dbi\">;\r\n\r\nexport class DBIInteractionLocale {\r\n name: string;\r\n data: TDBIInteractionLocaleData;\r\n dbi: DBI;\r\n constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {\r\n this.dbi = dbi;\r\n this.name = cfg.name;\r\n this.data = cfg.data;\r\n }\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContextMenu.d.ts","sourceRoot":"","sources":["../../src/types/MessageContextMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,oBAAY,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;AAEpH,MAAM,WAAW,gCAAiC,SAAQ,kBAAkB;IAC1E,WAAW,EAAE,OAAO,CAAC,oCAAoC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;CAC9E;AAGD,qBAAa,qBAAsB,SAAQ,kBAAkB;gBAC/C,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,6BAA6B;IAOxD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,gCAAgC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;CAC9E"}
1
+ {"version":3,"file":"MessageContextMenu.d.ts","sourceRoot":"","sources":["../../src/types/MessageContextMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,oBAAY,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;AAEpH,MAAM,WAAW,gCAAiC,SAAQ,kBAAkB;IAC1E,WAAW,EAAE,OAAO,CAAC,oCAAoC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;CAC9E;AAGD,qBAAa,qBAAsB,SAAQ,kBAAkB;gBAC/C,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,6BAA6B;IAUxD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,gCAAgC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;CAC9E"}
@@ -8,6 +8,8 @@ class DBIMessageContextMenu extends Interaction_1.DBIBaseInteraction {
8
8
  ...cfg,
9
9
  type: "MessageContextMenu"
10
10
  });
11
+ this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;
12
+ this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;
11
13
  }
12
14
  directMessages;
13
15
  defaultMemberPermissions;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContextMenu.js","sourceRoot":"","sources":["../../src/types/MessageContextMenu.ts"],"names":[],"mappings":";;;AACA,+CAAuE;AAUvE,MAAa,qBAAsB,SAAQ,gCAAkB;IAC3D,YAAY,GAAQ,EAAE,GAAkC;QACtD,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,oBAAoB;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAC9C,SAAS,CAAC,GAAqC,IAAuB,CAAC;CACjF;AAXD,sDAWC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\n\r\nexport type TDBIMessageContextMenuOmitted = Omit<DBIMessageContextMenu, \"type\" | \"description\" | \"dbi\" | \"options\">;\r\n\r\nexport interface IDBIMessageContextMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.MessageContextMenuCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\n\r\nexport class DBIMessageContextMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIMessageContextMenuOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"MessageContextMenu\"\r\n });\r\n }\r\n\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n override onExecute(ctx: IDBIMessageContextMenuExecuteCtx): Promise<any> | any {}\r\n}"]}
1
+ {"version":3,"file":"MessageContextMenu.js","sourceRoot":"","sources":["../../src/types/MessageContextMenu.ts"],"names":[],"mappings":";;;AACA,+CAAuE;AAUvE,MAAa,qBAAsB,SAAQ,gCAAkB;IAC3D,YAAY,GAAQ,EAAE,GAAkC;QACtD,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,oBAAoB;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/E,IAAI,CAAC,wBAAwB,GAAG,GAAG,CAAC,wBAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC/G,CAAC;IAED,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAC9C,SAAS,CAAC,GAAqC,IAAuB,CAAC;CACjF;AAdD,sDAcC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\n\r\nexport type TDBIMessageContextMenuOmitted = Omit<DBIMessageContextMenu, \"type\" | \"description\" | \"dbi\" | \"options\">;\r\n\r\nexport interface IDBIMessageContextMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.MessageContextMenuCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\n\r\nexport class DBIMessageContextMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIMessageContextMenuOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"MessageContextMenu\"\r\n });\r\n\r\n this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;\r\n this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;\r\n }\r\n\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n override onExecute(ctx: IDBIMessageContextMenuExecuteCtx): Promise<any> | any {}\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UserContextMenu.d.ts","sourceRoot":"","sources":["../../src/types/UserContextMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,oBAAY,0BAA0B,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;AAE9G,MAAM,WAAW,6BAA8B,SAAQ,kBAAkB;IACvE,WAAW,EAAE,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;CAC3E;AAED,qBAAa,kBAAmB,SAAQ,kBAAkB;gBAC5C,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,0BAA0B;IAMrD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,6BAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;CAC3E"}
1
+ {"version":3,"file":"UserContextMenu.d.ts","sourceRoot":"","sources":["../../src/types/UserContextMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,oBAAY,0BAA0B,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;AAE9G,MAAM,WAAW,6BAA8B,SAAQ,kBAAkB;IACvE,WAAW,EAAE,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;CAC3E;AAED,qBAAa,kBAAmB,SAAQ,kBAAkB;gBAC5C,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,0BAA0B;IASrD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,6BAA6B,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;CAC3E"}
@@ -8,6 +8,8 @@ class DBIUserContextMenu extends Interaction_1.DBIBaseInteraction {
8
8
  ...cfg,
9
9
  type: "UserContextMenu"
10
10
  });
11
+ this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;
12
+ this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;
11
13
  }
12
14
  directMessages;
13
15
  defaultMemberPermissions;
@@ -1 +1 @@
1
- {"version":3,"file":"UserContextMenu.js","sourceRoot":"","sources":["../../src/types/UserContextMenu.ts"],"names":[],"mappings":";;;AACA,+CAAuE;AASvE,MAAa,kBAAmB,SAAQ,gCAAkB;IACxD,YAAY,GAAQ,EAAE,GAA+B;QACnD,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,iBAAiB;SACxB,CAAC,CAAC;IACL,CAAC;IACD,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAC9C,SAAS,CAAC,GAAkC,IAAuB,CAAC;CAC9E;AAVD,gDAUC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\n\r\nexport type TDBIUserContextMenuOmitted = Omit<DBIUserContextMenu, \"type\" | \"description\" | \"dbi\" | \"options\">;\r\n\r\nexport interface IDBIUserContextMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.UserContextMenuCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\nexport class DBIUserContextMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIUserContextMenuOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"UserContextMenu\"\r\n });\r\n }\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n override onExecute(ctx: IDBIUserContextMenuExecuteCtx): Promise<any> | any {}\r\n}"]}
1
+ {"version":3,"file":"UserContextMenu.js","sourceRoot":"","sources":["../../src/types/UserContextMenu.ts"],"names":[],"mappings":";;;AACA,+CAAuE;AASvE,MAAa,kBAAmB,SAAQ,gCAAkB;IACxD,YAAY,GAAQ,EAAE,GAA+B;QACnD,KAAK,CAAC,GAAG,EAAE;YACT,GAAI,GAAW;YACf,IAAI,EAAE,iBAAiB;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/E,IAAI,CAAC,wBAAwB,GAAG,GAAG,CAAC,wBAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC/G,CAAC;IACD,cAAc,CAAW;IACzB,wBAAwB,CAA+B;IAC9C,SAAS,CAAC,GAAkC,IAAuB,CAAC;CAC9E;AAbD,gDAaC","sourcesContent":["import { DBI } from \"../DBI\";\r\nimport { DBIBaseInteraction, IDBIBaseExecuteCtx } from \"./Interaction\";\r\nimport Discord from \"discord.js\";\r\n\r\nexport type TDBIUserContextMenuOmitted = Omit<DBIUserContextMenu, \"type\" | \"description\" | \"dbi\" | \"options\">;\r\n\r\nexport interface IDBIUserContextMenuExecuteCtx extends IDBIBaseExecuteCtx {\r\n interaction: Discord.UserContextMenuCommandInteraction<Discord.CacheType>;\r\n}\r\n\r\nexport class DBIUserContextMenu extends DBIBaseInteraction {\r\n constructor(dbi: DBI, cfg: TDBIUserContextMenuOmitted) {\r\n super(dbi, {\r\n ...(cfg as any),\r\n type: \"UserContextMenu\"\r\n });\r\n\r\n this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;\r\n this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;\r\n }\r\n directMessages?: boolean;\r\n defaultMemberPermissions?: Discord.PermissionsString[];\r\n override onExecute(ctx: IDBIUserContextMenuExecuteCtx): Promise<any> | any {}\r\n}"]}
@@ -3,7 +3,7 @@ export declare class MemoryStore {
3
3
  constructor();
4
4
  get(key: string, defaultValue?: any): Promise<any>;
5
5
  set(key: string, value: any): Promise<any>;
6
- del(key: string): Promise<boolean>;
6
+ delete(key: string): Promise<boolean>;
7
7
  has(key: string): Promise<boolean>;
8
8
  }
9
9
  //# sourceMappingURL=MemoryStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IASlD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGzC"}
1
+ {"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IASlD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGzC"}
@@ -19,7 +19,7 @@ class MemoryStore {
19
19
  async set(key, value) {
20
20
  return this.store = lodash_1.default.set(this.store, key, value);
21
21
  }
22
- async del(key) {
22
+ async delete(key) {
23
23
  return lodash_1.default.unset(this.store, key);
24
24
  }
25
25
  async has(key) {
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryStore.js","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":";;;;AAAA,4DAAuB;AAEvB,MAAa,WAAW;IACtB,KAAK,CAAsB;IAC3B;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,YAAkB;QACvC,IAAI,GAAG,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE;YACR,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAC5B,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU;QAC/B,OAAO,IAAI,CAAC,KAAK,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACF;AAzBD,kCAyBC","sourcesContent":["import _ from \"lodash\";\r\n\r\nexport class MemoryStore {\r\n store: Record<string, any>;\r\n constructor() {\r\n this.store = {};\r\n }\r\n async get(key: string, defaultValue?: any): Promise<any> {\r\n let val = _.get(this.store, key);\r\n if (!val) {\r\n this.set(key, defaultValue);\r\n return defaultValue;\r\n }\r\n return val;\r\n }\r\n\r\n async set(key: string, value: any): Promise<any> {\r\n return this.store = _.set(this.store, key, value);\r\n }\r\n\r\n async del(key: string): Promise<boolean> {\r\n return _.unset(this.store, key);\r\n }\r\n\r\n async has(key: string): Promise<boolean> {\r\n return _.has(this.store, key);\r\n }\r\n}"]}
1
+ {"version":3,"file":"MemoryStore.js","sourceRoot":"","sources":["../../src/utils/MemoryStore.ts"],"names":[],"mappings":";;;;AAAA,4DAAuB;AAEvB,MAAa,WAAW;IACtB,KAAK,CAAsB;IAC3B;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,YAAkB;QACvC,IAAI,GAAG,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,EAAE;YACR,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAC5B,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU;QAC/B,OAAO,IAAI,CAAC,KAAK,GAAG,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,OAAO,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,gBAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACF;AAzBD,kCAyBC","sourcesContent":["import _ from \"lodash\";\r\n\r\nexport class MemoryStore {\r\n store: Record<string, any>;\r\n constructor() {\r\n this.store = {};\r\n }\r\n async get(key: string, defaultValue?: any): Promise<any> {\r\n let val = _.get(this.store, key);\r\n if (!val) {\r\n this.set(key, defaultValue);\r\n return defaultValue;\r\n }\r\n return val;\r\n }\r\n\r\n async set(key: string, value: any): Promise<any> {\r\n return this.store = _.set(this.store, key, value);\r\n }\r\n\r\n async delete(key: string): Promise<boolean> {\r\n return _.unset(this.store, key);\r\n }\r\n\r\n async has(key: string): Promise<boolean> {\r\n return _.has(this.store, key);\r\n }\r\n}"]}
package/package.json CHANGED
@@ -3,13 +3,13 @@
3
3
  "@discordjs/rest": "^1.0.1",
4
4
  "discord-api-types": "^0.37.0",
5
5
  "discord-hybrid-sharding": "^1.7.4",
6
- "discord.js": "^14.1.2",
6
+ "discord.js": "^14.3.0",
7
7
  "lodash": "^4.17.21",
8
8
  "snakecase-keys": "^5.4.2",
9
9
  "stuffs": "^0.1.17"
10
10
  },
11
11
  "name": "@mostfeatured/dbi",
12
- "version": "0.0.10",
12
+ "version": "0.0.13",
13
13
  "main": "dist/index.js",
14
14
  "type": "commonjs",
15
15
  "private": false,
package/src/DBI.ts CHANGED
@@ -15,11 +15,13 @@ import { hookEventListeners } from "./methods/hookEventListeners";
15
15
  import eventMap from "./data/eventMap.json";
16
16
  import { DBIModal, TDBIModalOmitted } from "./types/Modal";
17
17
  import * as Sharding from "discord-hybrid-sharding";
18
+ import _ from "lodash";
19
+ import { DBIInteractionLocale, TDBIInteractionLocaleOmitted } from "./types/InteractionLocale";
18
20
 
19
21
  export interface DBIStore {
20
22
  get(key: string, defaultValue?: any): Promise<any>;
21
23
  set(key: string, value: any): Promise<void>;
22
- del(key: string): Promise<void>;
24
+ delete(key: string): Promise<void>;
23
25
  has(key: string): Promise<boolean>;
24
26
  }
25
27
 
@@ -35,11 +37,29 @@ export interface DBIConfig {
35
37
  };
36
38
 
37
39
  sharding: boolean;
38
-
40
+ /**
41
+ * Persist store. (Default to MemoryStore thats not persis tho.)
42
+ */
39
43
  store: DBIStore;
40
44
  }
41
45
 
42
- export type TDBIConfigConstructor = Partial<DBIConfig>;
46
+ export interface DBIConfigConstructor {
47
+ discord: {
48
+ token: string;
49
+ options: Discord.ClientOptions
50
+ }
51
+ defaults?: {
52
+ locale?: TDBILocaleString,
53
+ directMessages?: boolean,
54
+ defaultMemberPermissions?: Discord.PermissionsString[]
55
+ };
56
+
57
+ sharding?: boolean;
58
+ /**
59
+ * Persist store. (Default to MemoryStore thats not persis tho.)
60
+ */
61
+ store?: DBIStore;
62
+ }
43
63
 
44
64
  export interface DBIRegisterAPI {
45
65
  ChatInput(cfg: TDBIChatInputOmitted): DBIChatInput;
@@ -50,11 +70,12 @@ export interface DBIRegisterAPI {
50
70
  SelectMenu(cfg: TDBISelectMenuOmitted): DBISelectMenu;
51
71
  MessageContextMenu(cfg: TDBIMessageContextMenuOmitted): DBIMessageContextMenu;
52
72
  UserContextMenu(cfg: TDBIUserContextMenuOmitted): DBIUserContextMenu;
73
+ InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;
53
74
  Modal(cfg: TDBIModalOmitted): DBIModal;
54
75
  onUnload(cb: () => Promise<any> | any): any;
55
76
  }
56
77
 
57
- export class DBI {
78
+ export class DBI<TOtherData = Record<string, any>> {
58
79
  namespace: string;
59
80
  config: DBIConfig;
60
81
  client: Discord.Client<true>;
@@ -63,7 +84,8 @@ export class DBI {
63
84
  events: Discord.Collection<string, DBIEvent>;
64
85
  plugins: Discord.Collection<string, any>;
65
86
  locales: Discord.Collection<string, DBILocale>;
66
- other: Record<string, any>;
87
+ interactionLocales: Discord.Collection<string, DBIInteractionLocale>;
88
+ other: TOtherData;
67
89
  eventMap: Record<string, string[]>;
68
90
  unloaders: Set<() => void>;
69
91
  registers: Set<(...args: any[]) => any>;
@@ -73,7 +95,7 @@ export class DBI {
73
95
  events: Events;
74
96
  cluster?: Sharding.Client;
75
97
  private _loaded: boolean;
76
- constructor(namespace: string, config: TDBIConfigConstructor) {
98
+ constructor(namespace: string, config: DBIConfigConstructor) {
77
99
  this.namespace = namespace;
78
100
 
79
101
  config.store = config.store as any || new MemoryStore();
@@ -93,7 +115,8 @@ export class DBI {
93
115
  events: new Discord.Collection(),
94
116
  plugins: new Discord.Collection(),
95
117
  locales: new Discord.Collection(),
96
- other: {},
118
+ interactionLocales: new Discord.Collection(),
119
+ other: {} as TOtherData,
97
120
  eventMap,
98
121
  unloaders: new Set(),
99
122
  registers: new Set(),
@@ -188,7 +211,6 @@ export class DBI {
188
211
  };
189
212
  Modal = Object.assign(Modal, class { constructor(...args: any[]) { return Modal.apply(this, args as any); } });
190
213
 
191
-
192
214
  let Locale = function(cfg: TDBILocaleConstructor) {
193
215
  let dbiLocale = new DBILocale(self, cfg);
194
216
  if (self.data.locales.has(dbiLocale.name)) throw new Error(`DBILocale "${dbiLocale.name}" already loaded!`);
@@ -197,6 +219,14 @@ export class DBI {
197
219
  };
198
220
  Locale = Object.assign(Locale, class { constructor(...args: any[]) { return Locale.apply(this, args as any); } });
199
221
 
222
+ let InteractionLocale = function(cfg: TDBIInteractionLocaleOmitted) {
223
+ let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);
224
+ if (self.data.interactionLocales.has(dbiInteractionLocale.name)) throw new Error(`DBIInteractionLocale "${dbiInteractionLocale.name}" already loaded!`);
225
+ self.data.interactionLocales.set(dbiInteractionLocale.name, dbiInteractionLocale);
226
+ return dbiInteractionLocale;
227
+ };
228
+ InteractionLocale = Object.assign(InteractionLocale, class { constructor(...args: any[]) { return InteractionLocale.apply(this, args as any); } });
229
+
200
230
  await cb({
201
231
  ChatInput,
202
232
  Event,
@@ -207,6 +237,7 @@ export class DBI {
207
237
  MessageContextMenu,
208
238
  UserContextMenu,
209
239
  Modal,
240
+ InteractionLocale,
210
241
  onUnload(cb: ()=> Promise<any> | any) {
211
242
  self.data.registerUnloaders.add(cb);
212
243
  },
@@ -214,6 +245,38 @@ export class DBI {
214
245
  }
215
246
  }
216
247
 
248
+ /**
249
+ * Shorthands for modifying `dbi.data.other`
250
+ */
251
+ get<K extends keyof TOtherData>(k: K, defaultValue?: TOtherData[K]): TOtherData[K] {
252
+ if (this.has(k as any)) {
253
+ this.set(k, defaultValue);
254
+ return defaultValue;
255
+ }
256
+ return _.get(this.data.other, k);
257
+ }
258
+
259
+ /**
260
+ * Shorthands for modifying `dbi.data.other`
261
+ */
262
+ set<K extends keyof TOtherData>(k: K, v: TOtherData[K]): any {
263
+ this.data.other = _.set(this.data.other as any, k, v);
264
+ }
265
+
266
+ /**
267
+ * Shorthands for modifying `dbi.data.other`
268
+ */
269
+ has(k: string): boolean {
270
+ return _.has(this.data.other, k as any);
271
+ }
272
+
273
+ /**
274
+ * Shorthands for modifying `dbi.data.other`
275
+ */
276
+ delete(k: string): boolean {
277
+ return _.unset(this.data.other, k);
278
+ }
279
+
217
280
  async login(): Promise<any> {
218
281
  await this.client.login(this.config.discord.token);
219
282
  }
@@ -250,6 +313,7 @@ export class DBI {
250
313
  return await publishInteractions(
251
314
  this.config.discord.token,
252
315
  args[1] ? new Discord.Collection() : interactions,
316
+ this.data.interactionLocales,
253
317
  args[0]
254
318
  );
255
319
  }
@@ -257,6 +321,7 @@ export class DBI {
257
321
  return await publishInteractions(
258
322
  this.config.discord.token,
259
323
  args[2] ? new Discord.Collection() : interactions,
324
+ this.data.interactionLocales,
260
325
  args[0],
261
326
  args[1]
262
327
  );
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { DBI, TDBIConfigConstructor } from "./DBI";
1
+ import { DBI, DBIConfigConstructor } from "./DBI";
2
2
  export { recursiveImport } from "./utils/recursiveImport";
3
3
  export { MemoryStore } from "./utils/MemoryStore";
4
4
 
5
- export function createDBI(namespace: string, cfg: TDBIConfigConstructor): DBI {
6
- return new DBI(namespace, cfg);
5
+ export function createDBI<TOtherType = Record<string, any>>(namespace: string, cfg: DBIConfigConstructor): DBI<TOtherType> {
6
+ return new DBI<TOtherType>(namespace, cfg);
7
7
  }
@@ -47,7 +47,7 @@ export function hookInteractionListeners(dbi: DBI): () => any {
47
47
  }
48
48
 
49
49
  let userLocaleName = inter.locale.split("-")[0];
50
- let userLocale = userLocaleName ? dbi.data.locales.get(userLocaleName) : dbi.data.locales.get(dbi.config.defaults.locale);
50
+ let userLocale = dbi.data.locales.has(userLocaleName) ? dbi.data.locales.get(userLocaleName) : dbi.data.locales.get(dbi.config.defaults.locale);
51
51
 
52
52
  let guildLocaleName = inter.guild ? inter.guild.preferredLocale.split("-")[0] : null;
53
53
  let guildLocale = guildLocaleName ? (dbi.data.locales.has(guildLocaleName) ? dbi.data.locales.get(guildLocaleName) : dbi.data.locales.get(dbi.config.defaults.locale)) : null;
@@ -72,7 +72,7 @@ export function hookInteractionListeners(dbi: DBI): () => any {
72
72
  let key = `RateLimit["${rateLimitKeyMap[type]}"]`;
73
73
  let val = await dbi.config.store.get(key);
74
74
  if (val && Date.now() > val.at + val.duration) {
75
- await dbi.config.store.del(key);
75
+ await dbi.config.store.delete(key);
76
76
  val = null;
77
77
  }
78
78
  if (val) {