trivious 1.6.0 → 1.6.1

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 (100) hide show
  1. package/dist/core/client/trivious.client.d.ts +1 -1
  2. package/dist/core/client/trivious.client.js.map +1 -1
  3. package/dist/core/commands/methods.command.d.ts +1 -1
  4. package/dist/core/commands/methods.command.js.map +1 -1
  5. package/dist/core/components/component.base.d.ts +1 -1
  6. package/dist/core/events/clientReady.d.ts +1 -1
  7. package/dist/core/events/interactionCreate.d.ts +1 -1
  8. package/dist/core/events/interactionCreate.js.map +1 -1
  9. package/dist/core/registry/command.registry.d.ts +1 -1
  10. package/dist/core/registry/command.registry.js.map +1 -1
  11. package/dist/core/registry/component.registry.d.ts +1 -1
  12. package/dist/core/registry/event.registry.d.ts +1 -1
  13. package/dist/core/registry/index.d.ts +1 -1
  14. package/dist/core/registry/module.registry.d.ts +1 -1
  15. package/dist/{index-D9od1fzU.d.ts → index-BqxT-x7T.d.ts} +55 -56
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +0 -1
  18. package/dist/shared/typings/commands.d.ts +2 -2
  19. package/dist/shared/typings/events.d.ts +1 -1
  20. package/dist/shared/typings/index.d.ts +1 -1
  21. package/dist/shared/typings/module.d.ts +1 -1
  22. package/dist/shared/utility/functions.d.ts +1 -1
  23. package/dist/shared/utility/permissions.utility.d.ts +1 -1
  24. package/package.json +1 -1
  25. package/dist/core/builders/util.builders.cjs +0 -15
  26. package/dist/core/builders/util.builders.cjs.map +0 -1
  27. package/dist/core/builders/util.builders.d.cts +0 -21
  28. package/dist/core/client/trivious.client.cjs +0 -119
  29. package/dist/core/client/trivious.client.cjs.map +0 -1
  30. package/dist/core/client/trivious.client.d.cts +0 -7
  31. package/dist/core/commands/command.base.cjs +0 -4
  32. package/dist/core/commands/command.base.cjs.map +0 -1
  33. package/dist/core/commands/command.base.d.cts +0 -7
  34. package/dist/core/commands/command.base.d.ts +0 -7
  35. package/dist/core/commands/command.base.js +0 -3
  36. package/dist/core/commands/command.base.js.map +0 -1
  37. package/dist/core/commands/methods.command.cjs +0 -55
  38. package/dist/core/commands/methods.command.cjs.map +0 -1
  39. package/dist/core/commands/methods.command.d.cts +0 -45
  40. package/dist/core/components/component.base.cjs +0 -4
  41. package/dist/core/components/component.base.cjs.map +0 -1
  42. package/dist/core/components/component.base.d.cts +0 -7
  43. package/dist/core/events/clientReady.cjs +0 -12
  44. package/dist/core/events/clientReady.cjs.map +0 -1
  45. package/dist/core/events/clientReady.d.cts +0 -14
  46. package/dist/core/events/interactionCreate.cjs +0 -90
  47. package/dist/core/events/interactionCreate.cjs.map +0 -1
  48. package/dist/core/events/interactionCreate.d.cts +0 -15
  49. package/dist/core/registry/command.registry.cjs +0 -60
  50. package/dist/core/registry/command.registry.cjs.map +0 -1
  51. package/dist/core/registry/command.registry.d.cts +0 -7
  52. package/dist/core/registry/component.registry.cjs +0 -47
  53. package/dist/core/registry/component.registry.cjs.map +0 -1
  54. package/dist/core/registry/component.registry.d.cts +0 -7
  55. package/dist/core/registry/event.registry.cjs +0 -77
  56. package/dist/core/registry/event.registry.cjs.map +0 -1
  57. package/dist/core/registry/event.registry.d.cts +0 -7
  58. package/dist/core/registry/index.cjs +0 -49
  59. package/dist/core/registry/index.cjs.map +0 -1
  60. package/dist/core/registry/index.d.cts +0 -23
  61. package/dist/core/registry/module.registry.cjs +0 -61
  62. package/dist/core/registry/module.registry.cjs.map +0 -1
  63. package/dist/core/registry/module.registry.d.cts +0 -7
  64. package/dist/index-C56Y6_f-.d.cts +0 -342
  65. package/dist/index.cjs +0 -63
  66. package/dist/index.cjs.map +0 -1
  67. package/dist/index.d.cts +0 -7
  68. package/dist/shared/typings/client.cjs +0 -4
  69. package/dist/shared/typings/client.cjs.map +0 -1
  70. package/dist/shared/typings/client.d.cts +0 -74
  71. package/dist/shared/typings/commands.cjs +0 -4
  72. package/dist/shared/typings/commands.cjs.map +0 -1
  73. package/dist/shared/typings/commands.d.cts +0 -7
  74. package/dist/shared/typings/components.cjs +0 -12
  75. package/dist/shared/typings/components.cjs.map +0 -1
  76. package/dist/shared/typings/components.d.cts +0 -40
  77. package/dist/shared/typings/events.cjs +0 -4
  78. package/dist/shared/typings/events.cjs.map +0 -1
  79. package/dist/shared/typings/events.d.cts +0 -7
  80. package/dist/shared/typings/index.cjs +0 -56
  81. package/dist/shared/typings/index.cjs.map +0 -1
  82. package/dist/shared/typings/index.d.cts +0 -7
  83. package/dist/shared/typings/module.cjs +0 -4
  84. package/dist/shared/typings/module.cjs.map +0 -1
  85. package/dist/shared/typings/module.d.cts +0 -7
  86. package/dist/shared/typings/permissions.cjs +0 -15
  87. package/dist/shared/typings/permissions.cjs.map +0 -1
  88. package/dist/shared/typings/permissions.d.cts +0 -16
  89. package/dist/shared/typings/registry.cjs +0 -63
  90. package/dist/shared/typings/registry.cjs.map +0 -1
  91. package/dist/shared/typings/registry.d.cts +0 -51
  92. package/dist/shared/utility/components.utility.cjs +0 -20
  93. package/dist/shared/utility/components.utility.cjs.map +0 -1
  94. package/dist/shared/utility/components.utility.d.cts +0 -19
  95. package/dist/shared/utility/functions.cjs +0 -89
  96. package/dist/shared/utility/functions.cjs.map +0 -1
  97. package/dist/shared/utility/functions.d.cts +0 -61
  98. package/dist/shared/utility/permissions.utility.cjs +0 -14
  99. package/dist/shared/utility/permissions.utility.cjs.map +0 -1
  100. package/dist/shared/utility/permissions.utility.d.cts +0 -17
@@ -1,4 +1,4 @@
1
- export { T as default } from '../../index-D9od1fzU.js';
1
+ export { T as default } from '../../index-BqxT-x7T.js';
2
2
  import 'discord.js';
3
3
  import '../../shared/typings/permissions.js';
4
4
  import '../../shared/typings/client.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":";;;;;;;AAiBA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,aAAa,UAAA,EA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,MAAA,IAAI,YAAY,OAAA,EAAS;AACxB,QAAA,OAAA,CAAQ,MAAM,CAAA,4DAAA,CAA8D,CAAA;AAC5E,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAC3C,MAAA,IAAI,CAAC,UAAA,CAAW,aAAa,CAAA,EAAG;AAC/B,QAAA,SAAA,CAAU,aAAA,EAAe,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,MAC7C;AAEA,MAAA,aAAA,CAAc,QAAA,EAAU,OAAA,EAAS,EAAE,QAAA,EAAU,SAAS,CAAA;AACtD,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,qCAAA,EAAwC,QAAQ,CAAA,CAAE,CAAA;AAAA,IACjE;AAEA,IAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,IAAI,MAAA,CAAO,mBAAA,CAAoB,QAAQ,CAAA,EAAG,EAAE,MAAM,CAAA;AAC7D,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.js","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { ContextMenuCommand, SlashCommand } from \"../commands/command.base.js\";\nimport { createHash } from \"node:crypto\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\treadonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\treadonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [\n\t\t\t...commands.map(command =>\n\t\t\t\t\"data\" in command ? (command as SlashCommand | ContextMenuCommand).data.toJSON() : null\n\t\t\t),\n\t\t].filter(c => c !== null);\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = createHash(\"sha256\")\n\t\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t\t.digest(\"hex\");\n\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hashDirectory = path.dirname(hashFile);\n\t\t\tif (!existsSync(hashDirectory)) {\n\t\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t\t}\n\n\t\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":";;;;;;;AAqBA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,aAAa,UAAA,EAAW;AAAA;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AI,YAAY,OAAA,EAAS;AACxB,QAAA,OAAA,CAAQ,MAAM,CAAA,4DAAA,CAA8D,CAAA;AAC5E,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAC3C,MAAA,IAAI,CAAC,UAAA,CAAW,aAAa,CAAA,EAAG;AAC/B,QAAA,SAAA,CAAU,aAAA,EAAe,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,MAC7C;AAEA,MAAA,aAAA,CAAc,QAAA,EAAU,OAAA,EAAS,EAAE,QAAA,EAAU,SAAS,CAAA;AACtD,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,qCAAA,EAAwC,QAAQ,CAAA,CAAE,CAAA;AAAA,IACjE;AAEA,IAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,IAAI,MAAA,CAAO,mBAAA,CAAoB,QAAQ,CAAA,EAAG,EAAE,MAAM,CAAA;AAC7D,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.js","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport {\n\tTriviousClientOptions,\n\tPermissionLevel,\n\tSlashCommand,\n\tContextMenuCommand,\n} from \"src/shared/typings/index.js\";\nimport { exists } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\treadonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\treadonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [\n\t\t\t...commands.map(command =>\n\t\t\t\t\"data\" in command ? (command as SlashCommand | ContextMenuCommand).data.toJSON() : null\n\t\t\t),\n\t\t].filter(c => c !== null);\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = createHash(\"sha256\")\n\t\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t\t.digest(\"hex\");\n\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hashDirectory = path.dirname(hashFile);\n\t\t\tif (!existsSync(hashDirectory)) {\n\t\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t\t}\n\n\t\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { MessagePayload, InteractionEditReplyOptions, InteractionReplyOptions } from 'discord.js';
2
- import { C as Command, a as ChatInputCommandInteraction, b as ContextMenuCommandInteraction, T as TriviousClient, S as SlashCommand } from '../../index-D9od1fzU.js';
2
+ import { C as Command, a as ChatInputCommandInteraction, b as ContextMenuCommandInteraction, T as TriviousClient, S as SlashCommand } from '../../index-BqxT-x7T.js';
3
3
  import { PermissionLevel } from '../../shared/typings/permissions.js';
4
4
  import '../../shared/typings/registry.js';
5
5
  import '../../shared/typings/components.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/commands/methods.command.ts"],"names":[],"mappings":";;;AAyBA,eAAsB,YAAA,CACrB,OAAA,EACA,WAAA,EACA,OAAA,EACC;AACD,EAAA,IAAI,WAAA,CAAY,OAAA,IAAW,WAAA,CAAY,QAAA,EAAU;AAChD,IAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,IAAA;AAAA,EACD;AAEA,EAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,EAAA,IAAI,OAAA,CAAQ,KAAA,IAAS,OAAA,CAAQ,KAAA,CAAM,QAAA,CAAS,gBAAgB,CAAA,EAAG,UAAA,CAAW,KAAA,GAAQ,CAAC,WAAW,CAAA;AAE9F,EAAA,MAAM,WAAA,CAAY,MAAM,UAAU,CAAA;AACnC;AAcA,eAAsB,sBACrB,MAAA,EACA,WAAA,EACA,OAAA,EACA,kBAAA,EACA,UAAmB,IAAA,EAClB;AACD,EAAA,IAAI,CAAC,WAAA,CAAY,OAAA,EAAQ,EAAG,OAAO,IAAA;AAEnC,EAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,EAAA,MAAM,sBAAsB,aAAA,CAAc,MAAA,EAAQ,EAAE,UAAA,EAAY,kBAAA,EAAoB,QAAQ,CAAA;AAE5F,EAAA,IAAI,CAAC,uBAAuB,OAAA,EAAS;AACpC,IAAA,MAAM,YAAA,CAAa,SAAS,WAAA,EAAa;AAAA,MACxC,OAAA,EAAS,CAAA,uEAAA,EAA0E,eAAA,CAAgB,kBAAkB,CAAC,CAAA,EAAA;AAAA,KACtH,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,mBAAA;AACR;AAYA,eAAsB,kBAAA,CACrB,MAAA,EACA,OAAA,EACA,WAAA,EACC;AACD,EAAA,MAAM,EAAE,SAAQ,GAAI,WAAA;AAEpB,EAAA,MAAM,UAAU,MAAM,qBAAA;AAAA,IACrB,MAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA,CAAQ,cAAc,eAAA,CAAgB,IAAA;AAAA,IACtC;AAAA,GACD;AAEA,EAAA,IAAI,KAAA,IAAS,OAAA,IAAW,OAAA,CAAQ,GAAA,IAAO,OAAA,EAAS;AAC/C,IAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,WAAW,CAAA;AAAA,EACtC;AAEA,EAAA,IAAI,CAAC,OAAA,EAAS;AACd,EAAA,IAAI,CAAC,OAAA,CAAQ,aAAA,CAAc,KAAK,CAAA,IAAK,EAAE,iBAAiB,OAAA,CAAA,EAAU;AAElE,EAAA,MAAM,cAAA,GAAiB,QAAQ,aAAA,EAAc;AAC7C,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,WAAA,CAAa,GAAA,CAAI,cAAc,CAAA;AAE1D,EAAA,IAAI,CAAC,UAAA,EAAY;AAChB,IAAA,MAAM,YAAA,CAAa,SAAS,WAAA,EAAa;AAAA,MACxC,OAAA,EAAS;AAAA,KACT,CAAA;AACD,IAAA;AAAA,EACD;AAEA,EAAA,MAAM,UAAA,CAAW,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAC7C","file":"methods.command.js","sourcesContent":["import {\n\tGuildMember,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tMessagePayload,\n} from \"discord.js\";\nimport {\n\tChatInputCommandInteraction,\n\tContextMenuCommandInteraction,\n\tPermissionLevel,\n\tTriviousClient,\n} from \"src/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport { Command, SlashCommand, SlashSubcommand } from \"./command.base.js\";\n\n/**\n * Reply to a command, respecting whether it has been deferred or already replied to.\n *\n * @export\n * @async\n * @param {Command} command\n * @param {ChatInputCommandInteraction | ContextMenuCommandInteraction} interaction\n * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options\n * @returns {*}\n */\nexport async function commandReply(\n\tcommand: Command,\n\tinteraction: ChatInputCommandInteraction | ContextMenuCommandInteraction,\n\toptions: MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions\n) {\n\tif (interaction.replied || interaction.deferred) {\n\t\tawait interaction.editReply(options as InteractionEditReplyOptions);\n\t\treturn;\n\t}\n\n\tconst newOptions = { ...options } as InteractionReplyOptions;\n\tif (command.flags && command.flags.includes(\"EphemeralReply\")) newOptions.flags = [\"Ephemeral\"];\n\n\tawait interaction.reply(newOptions);\n}\n\n/**\n * Compare a permission level to the guild member's permission level.\n *\n * @export\n * @async\n * @param {TriviousClient} client\n * @param {ChatInputCommandInteraction | ContextMenuCommandInteraction} interaction\n * @param {Command} command\n * @param {PermissionLevel} requiredPermission\n * @param {boolean} [doReply=true]\n * @returns {unknown}\n */\nexport async function verifyGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ChatInputCommandInteraction | ContextMenuCommandInteraction,\n\tcommand: Command,\n\trequiredPermission: PermissionLevel,\n\tdoReply: boolean = true\n) {\n\tif (!interaction.inGuild()) return true;\n\n\tconst member = interaction.member as GuildMember;\n\tconst memberHasPermission = hasPermission(client, { permission: requiredPermission, member });\n\n\tif (!memberHasPermission && doReply) {\n\t\tawait commandReply(command, interaction, {\n\t\t\tcontent: `You do not have permission to run this command, required permission: \\`${PermissionLevel[requiredPermission]}\\``,\n\t\t});\n\t}\n\n\treturn memberHasPermission;\n}\n\n/**\n * Handle execution of a slash command.\n *\n * @export\n * @async\n * @param {TriviousClient} client\n * @param {(SlashCommand | SlashSubcommand)} command\n * @param {ChatInputCommandInteraction} interaction\n * @returns {*}\n */\nexport async function handleSlashCommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommand,\n\tinteraction: ChatInputCommandInteraction\n) {\n\tconst { options } = interaction;\n\n\tconst hasPerm = await verifyGuildPermission(\n\t\tclient,\n\t\tinteraction,\n\t\tcommand,\n\t\tcommand.permission || PermissionLevel.USER,\n\t\ttrue\n\t);\n\n\tif (\"run\" in command && command.run && hasPerm) {\n\t\tawait command.run(client, interaction);\n\t}\n\n\tif (!hasPerm) return;\n\tif (!options.getSubcommand(false) || !(\"subcommands\" in command)) return;\n\n\tconst subcommandName = options.getSubcommand();\n\tconst subcommand = command.subcommands!.get(subcommandName) as SlashSubcommand | undefined;\n\n\tif (!subcommand) {\n\t\tawait commandReply(command, interaction, {\n\t\t\tcontent: \"This subcommand no longer exists or is not registered.\",\n\t\t});\n\t\treturn;\n\t}\n\n\tawait subcommand.execute(client, interaction);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/commands/methods.command.ts"],"names":[],"mappings":";;;AA2BA,eAAsB,YAAA,CACrB,OAAA,EACA,WAAA,EACA,OAAA,EACC;AACD,EAAA,IAAI,WAAA,CAAY,OAAA,IAAW,WAAA,CAAY,QAAA,EAAU;AAChD,IAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,IAAA;AAAA,EACD;AAEA,EAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,EAAA,IAAI,OAAA,CAAQ,KAAA,IAAS,OAAA,CAAQ,KAAA,CAAM,QAAA,CAAS,gBAAgB,CAAA,EAAG,UAAA,CAAW,KAAA,GAAQ,CAAC,WAAW,CAAA;AAE9F,EAAA,MAAM,WAAA,CAAY,MAAM,UAAU,CAAA;AACnC;AAcA,eAAsB,sBACrB,MAAA,EACA,WAAA,EACA,OAAA,EACA,kBAAA,EACA,UAAmB,IAAA,EAClB;AACD,EAAA,IAAI,CAAC,WAAA,CAAY,OAAA,EAAQ,EAAG,OAAO,IAAA;AAEnC,EAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,EAAA,MAAM,sBAAsB,aAAA,CAAc,MAAA,EAAQ,EAAE,UAAA,EAAY,kBAAA,EAAoB,QAAQ,C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n\tMessagePayload,\n} from \"discord.js\";\nimport {\n\tChatInputCommandInteraction,\n\tCommand,\n\tContextMenuCommandInteraction,\n\tPermissionLevel,\n\tSlashCommand,\n\tSlashSubcommand,\n\tTriviousClient,\n} from \"src/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\n\n/**\n * Reply to a command, respecting whether it has been deferred or already replied to.\n *\n * @export\n * @async\n * @param {Command} command\n * @param {ChatInputCommandInteraction | ContextMenuCommandInteraction} interaction\n * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options\n * @returns {*}\n */\nexport async function commandReply(\n\tcommand: Command,\n\tinteraction: ChatInputCommandInteraction | ContextMenuCommandInteraction,\n\toptions: MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions\n) {\n\tif (interaction.replied || interaction.deferred) {\n\t\tawait interaction.editReply(options as InteractionEditReplyOptions);\n\t\treturn;\n\t}\n\n\tconst newOptions = { ...options } as InteractionReplyOptions;\n\tif (command.flags && command.flags.includes(\"EphemeralReply\")) newOptions.flags = [\"Ephemeral\"];\n\n\tawait interaction.reply(newOptions);\n}\n\n/**\n * Compare a permission level to the guild member's permission level.\n *\n * @export\n * @async\n * @param {TriviousClient} client\n * @param {ChatInputCommandInteraction | ContextMenuCommandInteraction} interaction\n * @param {Command} command\n * @param {PermissionLevel} requiredPermission\n * @param {boolean} [doReply=true]\n * @returns {unknown}\n */\nexport async function verifyGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ChatInputCommandInteraction | ContextMenuCommandInteraction,\n\tcommand: Command,\n\trequiredPermission: PermissionLevel,\n\tdoReply: boolean = true\n) {\n\tif (!interaction.inGuild()) return true;\n\n\tconst member = interaction.member as GuildMember;\n\tconst memberHasPermission = hasPermission(client, { permission: requiredPermission, member });\n\n\tif (!memberHasPermission && doReply) {\n\t\tawait commandReply(command, interaction, {\n\t\t\tcontent: `You do not have permission to run this command, required permission: \\`${PermissionLevel[requiredPermission]}\\``,\n\t\t});\n\t}\n\n\treturn memberHasPermission;\n}\n\n/**\n * Handle execution of a slash command.\n *\n * @export\n * @async\n * @param {TriviousClient} client\n * @param {(SlashCommand | SlashSubcommand)} command\n * @param {ChatInputCommandInteraction} interaction\n * @returns {*}\n */\nexport async function handleSlashCommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommand,\n\tinteraction: ChatInputCommandInteraction\n) {\n\tconst { options } = interaction;\n\n\tconst hasPerm = await verifyGuildPermission(\n\t\tclient,\n\t\tinteraction,\n\t\tcommand,\n\t\tcommand.permission || PermissionLevel.USER,\n\t\ttrue\n\t);\n\n\tif (\"run\" in command && command.run && hasPerm) {\n\t\tawait command.run(client, interaction);\n\t}\n\n\tif (!hasPerm) return;\n\tif (!options.getSubcommand(false) || !(\"subcommands\" in command)) return;\n\n\tconst subcommandName = options.getSubcommand();\n\tconst subcommand = command.subcommands!.get(subcommandName) as SlashSubcommand | undefined;\n\n\tif (!subcommand) {\n\t\tawait commandReply(command, interaction, {\n\t\t\tcontent: \"This subcommand no longer exists or is not registered.\",\n\t\t});\n\t\treturn;\n\t}\n\n\tawait subcommand.execute(client, interaction);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import 'discord.js';
2
2
  import '../../shared/typings/permissions.js';
3
3
  import '../../shared/typings/components.js';
4
- export { j as Component } from '../../index-D9od1fzU.js';
4
+ export { l as Component } from '../../index-BqxT-x7T.js';
5
5
  import '../../shared/typings/registry.js';
6
6
  import '../../shared/typings/client.js';
7
7
  import '../builders/util.builders.js';
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { T as TriviousClient } from '../../index-D9od1fzU.js';
2
+ import { T as TriviousClient } from '../../index-BqxT-x7T.js';
3
3
  import '../../shared/typings/permissions.js';
4
4
  import '../../shared/typings/registry.js';
5
5
  import '../../shared/typings/components.js';
@@ -1,6 +1,6 @@
1
1
  import * as discord_js from 'discord.js';
2
2
  import { CacheType } from 'discord.js';
3
- import { T as TriviousClient } from '../../index-D9od1fzU.js';
3
+ import { T as TriviousClient } from '../../index-BqxT-x7T.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/registry.js';
6
6
  import '../../shared/typings/components.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["hasPermission"],"mappings":";;;;;;AAyBA,eAAe,gCAAA,CACd,MAAA,EACA,WAAA,EACA,UAAA,EACC;AACD,EAAA,IAAI,YAAY,KAAA,EAAO;AACtB,IAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,IAAA,MAAM,sBAAsB,aAAA,CAAc,MAAA,EAAQ,EAAE,UAAA,EAAY,QAAQ,CAAA;AACxE,IAAA,OAAO,mBAAA;AAAA,EACR;AAEA,EAAA,OAAO,KAAA;AACR;AAEA,IAAO,yBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,mBAAA;AAAA,EACN,OAAA,EAAS,OAAO,MAAA,EAAQ,WAAA,KAAgB;AACvC,IAAA,IAAI,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,sBAAqB,EAAG;AAC3E,MAAA,MAAM,EAAE,aAAY,GAAI,WAAA;AAExB,MAAA,MAAM,kBAAA,GAAqB,MAAA,CAAO,UAAA,CAAW,QAAA,CAAS,GAAA,EAAI;AAC1D,MAAA,MAAM,OAAA,GAAU,kBAAA,CAAmB,GAAA,CAAI,WAAW,CAAA;AAClD,MAAA,IAAI,CAAC,OAAA,EAAS;AACb,QAAA,MAAM,YAAY,KAAA,CAAM;AAAA,UACvB,OAAA,EAAS,CAAA,yDAAA,CAAA;AAAA,UACT,KAAA,EAAO,CAAC,WAAW;AAAA,SACnB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,qBAAqB,OAAA,CAAQ,UAAA;AACnC,MAAA,MAAMA,iBAAgB,MAAM,qBAAA;AAAA,QAC3B,MAAA;AAAA,QACA,WAAA;AAAA,QACA,OAAA;AAAA,QACA,sBAAsB,eAAA,CAAgB;AAAA,OACvC;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,CAAqB,GAAA,CAAI,IAAI,CAAA;AAC/C,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,YAAY,KAAA,CAAM;AAAA,UACvB,OAAA,EAAS,CAAA,yDAAA,CAAA;AAAA,UACT,KAAA,EAAO,CAAC,WAAW;AAAA,SACnB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,qBAAqB,SAAA,CAAU,UAAA;AACrC,MAAA,MAAMA,iBAAgB,MAAM,gCAAA;AAAA,QAC3B,MAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACD;AACA,MAAA,IAAI,CAACA,cAAAA,EAAe;AAEpB,MAAA,IAAI,CAAC,WAAA,CAAY,aAAA,EAAc,EAAG,MAAM,YAAY,WAAA,EAAY;AAChE,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tButtonInteraction,\n\tCacheType,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport {\n\tComponentInteraction,\n\tComponentType,\n\tEvent,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport {\n\tcommandReply,\n\thandleSlashCommand,\n\tverifyGuildPermission,\n} from \"../commands/methods.command.js\";\nimport { ContextMenuCommand, SlashCommand } from \"../commands/command.base.js\";\nimport { ChatInputCommandInteraction } from \"src/index.js\";\nimport { deconstructCustomId } from \"src/shared/utility/components.utility.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\nasync function validateComponentGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ComponentInteraction,\n\tpermission: PermissionLevel\n) {\n\tif (interaction.guild) {\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\t\treturn memberHasPermission;\n\t}\n\n\treturn false;\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\texecute: async (client, interaction) => {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst registeredCommands = client.registries.commands.get();\n\t\t\tconst command = registeredCommands.get(commandName);\n\t\t\tif (!command) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = command.permission;\n\t\t\tconst hasPermission = await verifyGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tcommand,\n\t\t\t\trequiredPermission || PermissionLevel.USER\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!(\"execute\" in command)) {\n\t\t\t\tawait commandReply(command, interaction, {\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t\"Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (command.flags?.includes(\"DeferReply\")) {\n\t\t\t\tawait commandReply(command, interaction, { content: \"Processing command...\" });\n\t\t\t}\n\n\t\t\tif (command.context === \"SlashCommand\" && \"data\" in command) {\n\t\t\t\tawait handleSlashCommand(\n\t\t\t\t\tclient,\n\t\t\t\t\tcommand as SlashCommand,\n\t\t\t\t\tinteraction as ChatInputCommandInteraction\n\t\t\t\t);\n\t\t\t} else if (command.context === \"ContextMenu\") {\n\t\t\t\tawait (command as ContextMenuCommand).execute(\n\t\t\t\t\tclient,\n\t\t\t\t\tinteraction as\n\t\t\t\t\t\t| UserContextMenuCommandInteraction<CacheType>\n\t\t\t\t\t\t| MessageContextMenuCommandInteraction<CacheType>\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { compType, tags, data } = deconstructCustomId(interaction.customId);\n\n\t\t\tif (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;\n\t\t\tif (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst registeredComponents = client.registries.components.get();\n\t\t\tconst component = registeredComponents.get(data);\n\t\t\tif (!component) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = component.permission;\n\t\t\tconst hasPermission = await validateComponentGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!interaction.isModalSubmit()) await interaction.deferUpdate();\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
1
+ {"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["hasPermission"],"mappings":";;;;;;AA0BA,eAAe,gCAAA,CACd,MAAA,EACA,WAAA,EACA,UAAA,EACC;AACD,EAAA,IAAI,YAAY,KAAA,EAAO;AACtB,IAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,IAAA,MAAM,sBAAsB,aAAA,CAAc,MAAA,EAAQ,EAAE,UAAA,EAAY,QAAQ,CAAA;AACxE,IAAA,OAAO,mBAAA;AAAA,EACR;AAEA,EAAA,OAAO,KAAA;AACR;AAEA,IAAO,yBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,mBAAA;AAAA,EACN,OAAA,EAAS,OAAO,MAAA,EAAQ,WAAA,KAAgB;AACvC,IAAA,IAAI,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,sBAAqB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ommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport {\n\tComponentInteraction,\n\tComponentType,\n\tContextMenuCommand,\n\tEvent,\n\tPermissionLevel,\n\tSlashCommand,\n} from \"src/shared/typings/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport {\n\tcommandReply,\n\thandleSlashCommand,\n\tverifyGuildPermission,\n} from \"../commands/methods.command.js\";\nimport { ChatInputCommandInteraction } from \"src/index.js\";\nimport { deconstructCustomId } from \"src/shared/utility/components.utility.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\nasync function validateComponentGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ComponentInteraction,\n\tpermission: PermissionLevel\n) {\n\tif (interaction.guild) {\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\t\treturn memberHasPermission;\n\t}\n\n\treturn false;\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\texecute: async (client, interaction) => {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst registeredCommands = client.registries.commands.get();\n\t\t\tconst command = registeredCommands.get(commandName);\n\t\t\tif (!command) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = command.permission;\n\t\t\tconst hasPermission = await verifyGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tcommand,\n\t\t\t\trequiredPermission || PermissionLevel.USER\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!(\"execute\" in command)) {\n\t\t\t\tawait commandReply(command, interaction, {\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t\"Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (command.flags?.includes(\"DeferReply\")) {\n\t\t\t\tawait commandReply(command, interaction, { content: \"Processing command...\" });\n\t\t\t}\n\n\t\t\tif (command.context === \"SlashCommand\" && \"data\" in command) {\n\t\t\t\tawait handleSlashCommand(\n\t\t\t\t\tclient,\n\t\t\t\t\tcommand as SlashCommand,\n\t\t\t\t\tinteraction as ChatInputCommandInteraction\n\t\t\t\t);\n\t\t\t} else if (command.context === \"ContextMenu\") {\n\t\t\t\tawait (command as ContextMenuCommand).execute(\n\t\t\t\t\tclient,\n\t\t\t\t\tinteraction as\n\t\t\t\t\t\t| UserContextMenuCommandInteraction<CacheType>\n\t\t\t\t\t\t| MessageContextMenuCommandInteraction<CacheType>\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { compType, tags, data } = deconstructCustomId(interaction.customId);\n\n\t\t\tif (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;\n\t\t\tif (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst registeredComponents = client.registries.components.get();\n\t\t\tconst component = registeredComponents.get(data);\n\t\t\tif (!component) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = component.permission;\n\t\t\tconst hasPermission = await validateComponentGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!interaction.isModalSubmit()) await interaction.deferUpdate();\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
@@ -1,6 +1,6 @@
1
1
  import 'discord.js';
2
2
  import '../../shared/typings/registry.js';
3
- export { c as default } from '../../index-D9od1fzU.js';
3
+ export { c as default } from '../../index-BqxT-x7T.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/components.js';
6
6
  import '../../shared/typings/client.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["fs"],"mappings":";;;;;;AAoBA,MAAO,wBAAsC,YAAA,CAAsB;AAAA,EACxD,KAAA,GAAQ,IAAI,UAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,UAAU,CAAC,CAAA,EAAG;AAC7E,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,SAAA,GAAY,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAC3C,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAEzC,MAAA,IAAI,WAAA,GAAc,EAAA;AAClB,MAAA,IAAI,MAAM,MAAA,CAAO,SAAS,CAAA,EAAG,WAAA,GAAc,SAAA;AAAA,WAAA,IAClC,MAAM,MAAA,CAAO,OAAO,CAAA,EAAG,WAAA,GAAc,OAAA;AAAA,WACzC;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uilder } from \"discord.js\";\nimport { BaseRegistry } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport {\n\tCommand,\n\tContextMenuCommand,\n\tSlashCommand,\n\tSlashSubcommand,\n} from \"../commands/command.base.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\n\n/**\n * Registry to load and get all commands.\n *\n * @export\n * @class CommandRegistry\n * @typedef {CommandRegistry}\n * @extends {BaseRegistry<AnyCommand>}\n */\nexport default class CommandRegistry extends BaseRegistry<Command> {\n\tprotected items = new Collection<string, Command>();\n\n\t/**\n\t * Load all commands and their subcommands\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"commands\" })]\n\t * @returns {unknown}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"commands\"))) {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst indexFile = join(fullPath, \"index.ts\");\n\t\t\tconst indexJs = join(fullPath, \"index.js\");\n\n\t\t\tlet commandFile = \"\";\n\t\t\tif (await exists(indexFile)) commandFile = indexFile;\n\t\t\telse if (await exists(indexJs)) commandFile = indexJs;\n\t\t\telse continue;\n\n\t\t\tconst command = (await this.importFile<Command>(commandFile)) as\n\t\t\t\t| SlashCommand\n\t\t\t\t| SlashSubcommand\n\t\t\t\t| ContextMenuCommand\n\t\t\t\t| null;\n\t\t\tif (!command || !command.active || !(\"data\" in command)) continue;\n\n\t\t\tif (\"subcommands\" in command) {\n\t\t\t\tconst subcommandFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\t\tfile =>\n\t\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t\t);\n\n\t\t\t\tfor (const file of subcommandFiles) {\n\t\t\t\t\tconst subcommand = await this.importFile<SlashSubcommand>(join(fullPath, file));\n\t\t\t\t\tif (!subcommand) continue;\n\t\t\t\t\tif (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tif (!command.subcommands) command.subcommands = new Collection<string, SlashSubcommand>();\n\t\t\t\t\tcommand.subcommands.set(subcommand.data.name, subcommand);\n\t\t\t\t\tcommand.data.addSubcommand(subcommand.data);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.items.set(command.data.name, command);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["fs"],"mappings":";;;;;;AAoBA,MAAO,wBAAsC,YAAA,CAAsB;AAAA,EACxD,KAAA,GAAQ,IAAI,UAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,UAAU,CAAC,CAAA,EAAG;AAC7E,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,SAAA,GAAY,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAC3C,MAAA,MAAM,OAAA,G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AAA,CAAW,IAAI,CAAA;AAAA,QAC3C;AAAA,MACD;AAEA,MAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,OAAA,CAAQ,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,IAC1C;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"command.registry.js","sourcesContent":["import { Collection, SlashCommandSubcommandBuilder } from \"discord.js\";\nimport {\n\tBaseRegistry,\n\tCommand,\n\tContextMenuCommand,\n\tSlashCommand,\n\tSlashSubcommand,\n} from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\n\n/**\n * Registry to load and get all commands.\n *\n * @export\n * @class CommandRegistry\n * @typedef {CommandRegistry}\n * @extends {BaseRegistry<AnyCommand>}\n */\nexport default class CommandRegistry extends BaseRegistry<Command> {\n\tprotected items = new Collection<string, Command>();\n\n\t/**\n\t * Load all commands and their subcommands\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"commands\" })]\n\t * @returns {unknown}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"commands\"))) {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst indexFile = join(fullPath, \"index.ts\");\n\t\t\tconst indexJs = join(fullPath, \"index.js\");\n\n\t\t\tlet commandFile = \"\";\n\t\t\tif (await exists(indexFile)) commandFile = indexFile;\n\t\t\telse if (await exists(indexJs)) commandFile = indexJs;\n\t\t\telse continue;\n\n\t\t\tconst command = (await this.importFile<Command>(commandFile)) as\n\t\t\t\t| SlashCommand\n\t\t\t\t| ContextMenuCommand\n\t\t\t\t| null;\n\t\t\tif (!command || !command.active || !(\"data\" in command)) continue;\n\n\t\t\tif (\"subcommands\" in command) {\n\t\t\t\tconst subcommandFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\t\tfile =>\n\t\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t\t);\n\n\t\t\t\tfor (const file of subcommandFiles) {\n\t\t\t\t\tconst subcommand = await this.importFile<SlashSubcommand>(join(fullPath, file));\n\t\t\t\t\tif (!subcommand) continue;\n\t\t\t\t\tif (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tif (!command.subcommands) command.subcommands = new Collection<string, SlashSubcommand>();\n\t\t\t\t\tcommand.subcommands.set(subcommand.data.name, subcommand);\n\t\t\t\t\tcommand.data.addSubcommand(subcommand.data);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.items.set(command.data.name, command);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import 'discord.js';
2
2
  import '../../shared/typings/registry.js';
3
- export { d as default } from '../../index-D9od1fzU.js';
3
+ export { d as default } from '../../index-BqxT-x7T.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/components.js';
6
6
  import '../../shared/typings/client.js';
@@ -1,6 +1,6 @@
1
1
  import 'discord.js';
2
2
  import '../../shared/typings/registry.js';
3
- export { E as default } from '../../index-D9od1fzU.js';
3
+ export { E as default } from '../../index-BqxT-x7T.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/components.js';
6
6
  import '../../shared/typings/client.js';
@@ -1,5 +1,5 @@
1
1
  import { TriviousClientOptions } from '../../shared/typings/client.js';
2
- import { c as CommandRegistry, d as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, T as TriviousClient } from '../../index-D9od1fzU.js';
2
+ import { c as CommandRegistry, d as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, T as TriviousClient } from '../../index-BqxT-x7T.js';
3
3
  import 'discord.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/registry.js';
@@ -1,6 +1,6 @@
1
1
  import 'discord.js';
2
2
  import '../../shared/typings/registry.js';
3
- export { M as default } from '../../index-D9od1fzU.js';
3
+ export { M as default } from '../../index-BqxT-x7T.js';
4
4
  import '../../shared/typings/permissions.js';
5
5
  import '../../shared/typings/components.js';
6
6
  import '../../shared/typings/client.js';
@@ -2,9 +2,62 @@ import { PermissionLevel } from './shared/typings/permissions.js';
2
2
  import { BaseRegistry } from './shared/typings/registry.js';
3
3
  import { ComponentInteraction } from './shared/typings/components.js';
4
4
  import { TriviousClientOptions } from './shared/typings/client.js';
5
- import { ClientEvents, Collection, ComponentType, ContextMenuCommandBuilder, MessageContextMenuCommandInteraction, CacheType, UserContextMenuCommandInteraction, SlashCommandBuilder, SlashCommandSubcommandBuilder, Client, ChatInputCommandInteraction as ChatInputCommandInteraction$1, ButtonInteraction as ButtonInteraction$1, StringSelectMenuInteraction as StringSelectMenuInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, ContextMenuCommandInteraction as ContextMenuCommandInteraction$1 } from 'discord.js';
5
+ import { SlashCommandBuilder, Collection, SlashCommandSubcommandBuilder, ContextMenuCommandBuilder, MessageContextMenuCommandInteraction, CacheType, UserContextMenuCommandInteraction, ClientEvents, ComponentType, Client, ChatInputCommandInteraction as ChatInputCommandInteraction$1, ButtonInteraction as ButtonInteraction$1, StringSelectMenuInteraction as StringSelectMenuInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, ContextMenuCommandInteraction as ContextMenuCommandInteraction$1 } from 'discord.js';
6
6
  import './core/builders/util.builders.js';
7
7
 
8
+ /**
9
+ * Base command interface.
10
+ *
11
+ * @export
12
+ * @interface Command
13
+ * @typedef {Command}
14
+ */
15
+ interface Command {
16
+ readonly context: CommandContext;
17
+ readonly active: boolean;
18
+ readonly flags?: CommandFlags[];
19
+ readonly permission?: PermissionLevel;
20
+ }
21
+ /**
22
+ * Slash command interface.
23
+ *
24
+ * @export
25
+ * @interface SlashCommand
26
+ * @typedef {SlashCommand}
27
+ * @extends {Command}
28
+ */
29
+ interface SlashCommand extends Command {
30
+ readonly context: "SlashCommand";
31
+ readonly data: SlashCommandBuilder;
32
+ subcommands?: Collection<string, Command>;
33
+ readonly run?: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
34
+ }
35
+ /**
36
+ * Slash command subcommand interface.
37
+ *
38
+ * @export
39
+ * @interface SlashSubcommand
40
+ * @typedef {SlashSubcommand}
41
+ * @extends {Command}
42
+ */
43
+ interface SlashSubcommand extends Command {
44
+ readonly context: "SlashSubcommand";
45
+ readonly data: SlashCommandSubcommandBuilder;
46
+ readonly execute: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
47
+ }
48
+ /**
49
+ * Context menu command interface.
50
+ *
51
+ * @export
52
+ * @interface ContextMenuCommand
53
+ * @typedef {ContextMenuCommand}
54
+ * @extends {Command}
55
+ */
56
+ interface ContextMenuCommand extends Command {
57
+ readonly context: "ContextMenu";
58
+ readonly data: ContextMenuCommandBuilder;
59
+ readonly execute: (client: TriviousClient, interaction: MessageContextMenuCommandInteraction<CacheType> | UserContextMenuCommandInteraction<CacheType>) => Promise<void>;
60
+ }
8
61
  /**
9
62
  * Literal type for possible CommandInteractions.
10
63
  *
@@ -191,60 +244,6 @@ declare class ComponentRegistry extends BaseRegistry<Component> {
191
244
  load(directory?: string): Promise<this>;
192
245
  }
193
246
 
194
- /**
195
- * Base command interface.
196
- *
197
- * @export
198
- * @interface Command
199
- * @typedef {Command}
200
- */
201
- interface Command {
202
- readonly context: CommandContext;
203
- readonly active: boolean;
204
- readonly flags?: CommandFlags[];
205
- readonly permission?: PermissionLevel;
206
- }
207
- /**
208
- * Slash command interface.
209
- *
210
- * @export
211
- * @interface SlashCommand
212
- * @typedef {SlashCommand}
213
- * @extends {Command}
214
- */
215
- interface SlashCommand extends Command {
216
- readonly context: "SlashCommand";
217
- readonly data: SlashCommandBuilder;
218
- subcommands?: Collection<string, Command>;
219
- readonly run?: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
220
- }
221
- /**
222
- * Slash command subcommand interface.
223
- *
224
- * @export
225
- * @interface SlashSubcommand
226
- * @typedef {SlashSubcommand}
227
- * @extends {Command}
228
- */
229
- interface SlashSubcommand extends Command {
230
- readonly context: "SlashSubcommand";
231
- readonly data: SlashCommandSubcommandBuilder;
232
- readonly execute: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
233
- }
234
- /**
235
- * Context menu command interface.
236
- *
237
- * @export
238
- * @interface ContextMenuCommand
239
- * @typedef {ContextMenuCommand}
240
- * @extends {Command}
241
- */
242
- interface ContextMenuCommand extends Command {
243
- readonly context: "ContextMenu";
244
- readonly data: ContextMenuCommandBuilder;
245
- readonly execute: (client: TriviousClient, interaction: MessageContextMenuCommandInteraction<CacheType> | UserContextMenuCommandInteraction<CacheType>) => Promise<void>;
246
- }
247
-
248
247
  /**
249
248
  * Registry to load and get all commands.
250
249
  *
@@ -339,4 +338,4 @@ type StringSelectMenuInteraction = StringSelectMenuInteraction$1<CacheType>;
339
338
  type ModalSubmitInteraction = ModalSubmitInteraction$1<CacheType>;
340
339
  type ContextMenuCommandInteraction = ContextMenuCommandInteraction$1<CacheType>;
341
340
 
342
- export { type ButtonInteraction as B, type Command as C, EventRegistry as E, ModuleRegistry as M, type SlashCommand as S, TriviousClient as T, type ChatInputCommandInteraction as a, type ContextMenuCommandInteraction as b, CommandRegistry as c, ComponentRegistry as d, type CommandInteraction as e, type CommandFlags as f, type CommandContext as g, type Event as h, type Module as i, type Component as j, type SlashSubcommand as k, type ContextMenuCommand as l, type StringSelectMenuInteraction as m, type ModalSubmitInteraction as n };
341
+ export { type ButtonInteraction as B, type Command as C, EventRegistry as E, ModuleRegistry as M, type SlashCommand as S, TriviousClient as T, type ChatInputCommandInteraction as a, type ContextMenuCommandInteraction as b, CommandRegistry as c, ComponentRegistry as d, type SlashSubcommand as e, type ContextMenuCommand as f, type CommandInteraction as g, type CommandFlags as h, type CommandContext as i, type Event as j, type Module as k, type Component as l, type StringSelectMenuInteraction as m, type ModalSubmitInteraction as n };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { B as ButtonInteraction, a as ChatInputCommandInteraction, C as Command, g as CommandContext, f as CommandFlags, e as CommandInteraction, c as CommandRegistry, d as ComponentRegistry, l as ContextMenuCommand, b as ContextMenuCommandInteraction, h as Event, n as ModalSubmitInteraction, i as Module, S as SlashCommand, k as SlashSubcommand, m as StringSelectMenuInteraction, T as TriviousClient } from './index-D9od1fzU.js';
2
+ export { B as ButtonInteraction, a as ChatInputCommandInteraction, C as Command, i as CommandContext, h as CommandFlags, g as CommandInteraction, c as CommandRegistry, d as ComponentRegistry, f as ContextMenuCommand, b as ContextMenuCommandInteraction, j as Event, n as ModalSubmitInteraction, k as Module, S as SlashCommand, e as SlashSubcommand, m as StringSelectMenuInteraction, T as TriviousClient } from './index-BqxT-x7T.js';
3
3
  export { createActionRow, createEmbed } from './core/builders/util.builders.js';
4
4
  export { PermissionLevel } from './shared/typings/permissions.js';
5
5
  export { BaseRegistry } from './shared/typings/registry.js';
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import 'dotenv/config';
2
2
  import 'node:util';
3
3
  export { default as TriviousClient } from './core/client/trivious.client.js';
4
- export { Command, ContextMenuCommand, SlashCommand, SlashSubcommand } from './core/commands/command.base.js';
5
4
  export { default as CommandRegistry } from './core/registry/command.registry.js';
6
5
  export { default as ComponentRegistry } from './core/registry/component.registry.js';
7
6
  export { createActionRow, createEmbed } from './core/builders/util.builders.js';
@@ -1,7 +1,7 @@
1
- export { g as CommandContext, f as CommandFlags, e as CommandInteraction } from '../../index-D9od1fzU.js';
2
1
  import './permissions.js';
3
- import './registry.js';
4
2
  import 'discord.js';
3
+ export { C as Command, i as CommandContext, h as CommandFlags, g as CommandInteraction, f as ContextMenuCommand, S as SlashCommand, e as SlashSubcommand } from '../../index-BqxT-x7T.js';
4
+ import './registry.js';
5
5
  import './components.js';
6
6
  import './client.js';
7
7
  import '../../core/builders/util.builders.js';
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { h as Event } from '../../index-D9od1fzU.js';
2
+ export { j as Event } from '../../index-BqxT-x7T.js';
3
3
  import './permissions.js';
4
4
  import './registry.js';
5
5
  import './components.js';
@@ -1,7 +1,7 @@
1
1
  export { PermissionLevel } from './permissions.js';
2
2
  export { BaseRegistry } from './registry.js';
3
3
  export { ComponentCustomIdTag, ComponentInteraction, ComponentType, CustomIdConstructOptions } from './components.js';
4
- export { g as CommandContext, f as CommandFlags, e as CommandInteraction, h as Event, i as Module } from '../../index-D9od1fzU.js';
4
+ export { C as Command, i as CommandContext, h as CommandFlags, g as CommandInteraction, f as ContextMenuCommand, j as Event, k as Module, S as SlashCommand, e as SlashSubcommand } from '../../index-BqxT-x7T.js';
5
5
  export { TriviousClientOptions } from './client.js';
6
6
  import 'discord.js';
7
7
  import '../../core/builders/util.builders.js';
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { i as Module } from '../../index-D9od1fzU.js';
2
+ export { k as Module } from '../../index-BqxT-x7T.js';
3
3
  import './permissions.js';
4
4
  import './registry.js';
5
5
  import './components.js';
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../index-D9od1fzU.js';
1
+ import { T as TriviousClient } from '../../index-BqxT-x7T.js';
2
2
  import { PermissionLevel } from '../typings/permissions.js';
3
3
  import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
4
4
  import '../typings/registry.js';
@@ -1,6 +1,6 @@
1
1
  import { GuildMember } from 'discord.js';
2
2
  import { PermissionLevel } from '../typings/permissions.js';
3
- import { T as TriviousClient } from '../../index-D9od1fzU.js';
3
+ import { T as TriviousClient } from '../../index-BqxT-x7T.js';
4
4
  import '../typings/registry.js';
5
5
  import '../typings/components.js';
6
6
  import '../typings/client.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trivious",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var discord_js = require('discord.js');
4
-
5
- function createActionRow(...builders) {
6
- return new discord_js.ActionRowBuilder().setComponents(...builders);
7
- }
8
- function createEmbed(data) {
9
- return new discord_js.EmbedBuilder(data);
10
- }
11
-
12
- exports.createActionRow = createActionRow;
13
- exports.createEmbed = createEmbed;
14
- //# sourceMappingURL=util.builders.cjs.map
15
- //# sourceMappingURL=util.builders.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":["ActionRowBuilder","EmbedBuilder"],"mappings":";;;;AAgBO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAIA,2BAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AASO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAIC,wBAAa,IAAI,CAAA;AAC7B","file":"util.builders.cjs","sourcesContent":["import {\n\tActionRowBuilder,\n\tAPIEmbed,\n\tEmbedBuilder,\n\tEmbedData,\n\tMessageActionRowComponentBuilder,\n} from \"discord.js\";\n\n/**\n * Utility action row builder\n *\n * @export\n * @template {MessageActionRowComponentBuilder} T\n * @param {...T[]} builders\n * @returns {*}\n */\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\n/**\n * Utility embed builder\n *\n * @export\n * @param {?(EmbedData | APIEmbed)} [data]\n * @returns {*}\n */\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
@@ -1,21 +0,0 @@
1
- import { MessageActionRowComponentBuilder, ActionRowBuilder, EmbedData, APIEmbed, EmbedBuilder } from 'discord.js';
2
-
3
- /**
4
- * Utility action row builder
5
- *
6
- * @export
7
- * @template {MessageActionRowComponentBuilder} T
8
- * @param {...T[]} builders
9
- * @returns {*}
10
- */
11
- declare function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]): ActionRowBuilder<T>;
12
- /**
13
- * Utility embed builder
14
- *
15
- * @export
16
- * @param {?(EmbedData | APIEmbed)} [data]
17
- * @returns {*}
18
- */
19
- declare function createEmbed(data?: EmbedData | APIEmbed): EmbedBuilder;
20
-
21
- export { createActionRow, createEmbed };
@@ -1,119 +0,0 @@
1
- 'use strict';
2
-
3
- var discord_js = require('discord.js');
4
- var index_js = require('../registry/index.js');
5
- var functions_js = require('../../shared/utility/functions.js');
6
- var path = require('node:path');
7
- var node_fs = require('node:fs');
8
- var node_crypto = require('node:crypto');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var path__default = /*#__PURE__*/_interopDefault(path);
13
-
14
- class TriviousClient extends discord_js.Client {
15
- /**
16
- * Client registries.
17
- *
18
- * @public
19
- * @readonly
20
- * @type {*}
21
- */
22
- registries = index_js.registries();
23
- /**
24
- * Client copy of the constructor options.
25
- *
26
- * @private
27
- * @type {TriviousClientOptions}
28
- */
29
- _options;
30
- /**
31
- * Creates an instance of TriviousClient.
32
- *
33
- * @constructor
34
- * @param {TriviousClientOptions} options
35
- */
36
- constructor(options) {
37
- super(options);
38
- this._options = options;
39
- }
40
- /**
41
- * Load all registries.
42
- *
43
- * @async
44
- * @returns {*}
45
- */
46
- async register() {
47
- const { registries: registries2 } = this;
48
- await registries2.loadAll(this._options);
49
- console.log(
50
- `[Trivious] Loaded all registries (${registries2.commands.get().size} commands, ${registries2.events.get().size} events, ${registries2.components.get().size} components, ${registries2.modules.get().size} modules)`
51
- );
52
- }
53
- /**
54
- * Login and start the bot.
55
- *
56
- * @async
57
- * @returns {*}
58
- */
59
- async start() {
60
- if (!process.env[this._options.tokenReference]) {
61
- if (process.env.NODE_ENV !== "production") return;
62
- else throw new Error("[Trivious] Invalid token reference");
63
- }
64
- this.registries.bind(this);
65
- await this.login(process.env[this._options.tokenReference]);
66
- }
67
- /**
68
- * Deploy all commands.
69
- *
70
- * @async
71
- * @returns {*}
72
- */
73
- async deploy() {
74
- const { commandHashConfig } = this._options;
75
- const clientId = process.env[this._options.clientIdReference];
76
- const token = process.env[this._options.tokenReference];
77
- if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
78
- const commands = Array.from(this.registries.commands.get().values());
79
- const body = [
80
- ...commands.map(
81
- (command) => "data" in command ? command.data.toJSON() : null
82
- )
83
- ].filter((c) => c !== null);
84
- if (commandHashConfig && commandHashConfig.enabled) {
85
- const hashFile = path__default.default.join(commandHashConfig.filePath || "data", "commands.hash");
86
- const newHash = node_crypto.createHash("sha256").update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString()).digest("hex");
87
- let oldHash = "";
88
- if (await functions_js.exists(hashFile)) oldHash = node_fs.readFileSync(hashFile, "utf-8");
89
- if (newHash === oldHash) {
90
- console.debug(`[Trivious] No changes in commands found, skipping deployment`);
91
- return;
92
- }
93
- const hashDirectory = path__default.default.dirname(hashFile);
94
- if (!node_fs.existsSync(hashDirectory)) {
95
- node_fs.mkdirSync(hashDirectory, { recursive: true });
96
- }
97
- node_fs.writeFileSync(hashFile, newHash, { encoding: "utf-8" });
98
- console.debug(`[Trivious] Created new command hash: ${hashFile}`);
99
- }
100
- const rest = new discord_js.REST({ version: "10" }).setToken(token);
101
- await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
102
- console.log(`[Trivious] Deployed ${body.length} commands`);
103
- }
104
- /**
105
- * Set the roles tied to a permission level.
106
- *
107
- * @param {Record<string, PermissionLevel>} roles
108
- */
109
- setRolePermissions(roles) {
110
- this._options.rolePermissions = roles;
111
- }
112
- get rolePermissions() {
113
- return this._options.rolePermissions ?? {};
114
- }
115
- }
116
-
117
- module.exports = TriviousClient;
118
- //# sourceMappingURL=trivious.client.cjs.map
119
- //# sourceMappingURL=trivious.client.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","path","createHash","exists","readFileSync","existsSync","mkdirSync","writeFileSync","REST","Routes"],"mappings":";;;;;;;;;;;;;AAiBA,MAAO,uBAAqCA,iBAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,aAAaC,mBAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQT,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,QAAA,GAAW;AAChB,IAAA,MAAM,EAAE,UAAA,EAAAA,WAAAA,EAAW,GAAI,IAAA;AACvB,IAAA,MAAMA,WAAAA,CAAW,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA;AACtC,IAAA,OAAA,CAAQ,GAAA;AAAA,MACP,CAAA,kCAAA,EAAqCA,YAAW,QAAA,CAAS,GAAA,GAAM,IAAI,CAAA,WAAA,EAAcA,WAAAA,CAAW,MAAA,CAAO,GAAA,EAAI,CAAE,IAAI,CAAA,SAAA,EAAYA,WAAAA,CAAW,UAAA,CAAW,GAAA,EAAI,CAAE,IAAI,gBAAgBA,WAAAA,CAAW,OAAA,CAAQ,GAAA,EAAI,CAAE,IAAI,CAAA,SAAA;AAAA,KACvM;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,KAAA,GAAQ;AACb,IAAA,IAAI,CAAC,OAAA,CAAQ,GAA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AAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.cjs","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { ContextMenuCommand, SlashCommand } from \"../commands/command.base.js\";\nimport { createHash } from \"node:crypto\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\treadonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\treadonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [\n\t\t\t...commands.map(command =>\n\t\t\t\t\"data\" in command ? (command as SlashCommand | ContextMenuCommand).data.toJSON() : null\n\t\t\t),\n\t\t].filter(c => c !== null);\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = createHash(\"sha256\")\n\t\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t\t.digest(\"hex\");\n\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hashDirectory = path.dirname(hashFile);\n\t\t\tif (!existsSync(hashDirectory)) {\n\t\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t\t}\n\n\t\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
@@ -1,7 +0,0 @@
1
- export { T as default } from '../../index-C56Y6_f-.cjs';
2
- import 'discord.js';
3
- import '../../shared/typings/permissions.cjs';
4
- import '../../shared/typings/client.cjs';
5
- import '../../shared/typings/registry.cjs';
6
- import '../../shared/typings/components.cjs';
7
- import '../builders/util.builders.cjs';