trivious 1.5.11 → 1.6.0

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 (101) hide show
  1. package/dist/core/builders/util.builders.cjs.map +1 -1
  2. package/dist/core/builders/util.builders.js.map +1 -1
  3. package/dist/core/client/trivious.client.cjs +7 -2
  4. package/dist/core/client/trivious.client.cjs.map +1 -1
  5. package/dist/core/client/trivious.client.d.cts +4 -1
  6. package/dist/core/client/trivious.client.d.ts +4 -1
  7. package/dist/core/client/trivious.client.js +8 -3
  8. package/dist/core/client/trivious.client.js.map +1 -1
  9. package/dist/core/commands/command.base.cjs +0 -312
  10. package/dist/core/commands/command.base.cjs.map +1 -1
  11. package/dist/core/commands/command.base.d.cts +4 -1
  12. package/dist/core/commands/command.base.d.ts +4 -1
  13. package/dist/core/commands/command.base.js +0 -305
  14. package/dist/core/commands/command.base.js.map +1 -1
  15. package/dist/core/commands/methods.command.cjs +55 -0
  16. package/dist/core/commands/methods.command.cjs.map +1 -0
  17. package/dist/core/commands/methods.command.d.cts +45 -0
  18. package/dist/core/commands/methods.command.d.ts +45 -0
  19. package/dist/core/commands/methods.command.js +51 -0
  20. package/dist/core/commands/methods.command.js.map +1 -0
  21. package/dist/core/components/component.base.d.cts +7 -2
  22. package/dist/core/components/component.base.d.ts +7 -2
  23. package/dist/core/events/clientReady.d.cts +4 -1
  24. package/dist/core/events/clientReady.d.ts +4 -1
  25. package/dist/core/events/interactionCreate.cjs +21 -11
  26. package/dist/core/events/interactionCreate.cjs.map +1 -1
  27. package/dist/core/events/interactionCreate.d.cts +6 -2
  28. package/dist/core/events/interactionCreate.d.ts +6 -2
  29. package/dist/core/events/interactionCreate.js +21 -11
  30. package/dist/core/events/interactionCreate.js.map +1 -1
  31. package/dist/core/registry/command.registry.cjs +4 -4
  32. package/dist/core/registry/command.registry.cjs.map +1 -1
  33. package/dist/core/registry/command.registry.d.cts +4 -1
  34. package/dist/core/registry/command.registry.d.ts +4 -1
  35. package/dist/core/registry/command.registry.js +4 -4
  36. package/dist/core/registry/command.registry.js.map +1 -1
  37. package/dist/core/registry/component.registry.cjs.map +1 -1
  38. package/dist/core/registry/component.registry.d.cts +4 -1
  39. package/dist/core/registry/component.registry.d.ts +4 -1
  40. package/dist/core/registry/component.registry.js.map +1 -1
  41. package/dist/core/registry/event.registry.d.cts +4 -1
  42. package/dist/core/registry/event.registry.d.ts +4 -1
  43. package/dist/core/registry/index.d.cts +5 -2
  44. package/dist/core/registry/index.d.ts +5 -2
  45. package/dist/core/registry/module.registry.d.cts +4 -1
  46. package/dist/core/registry/module.registry.d.ts +4 -1
  47. package/dist/index-C56Y6_f-.d.cts +342 -0
  48. package/dist/index-D9od1fzU.d.ts +342 -0
  49. package/dist/index.cjs +3 -18
  50. package/dist/index.d.cts +4 -1
  51. package/dist/index.d.ts +4 -1
  52. package/dist/index.js +1 -2
  53. package/dist/shared/typings/client.d.cts +74 -4
  54. package/dist/shared/typings/client.d.ts +74 -4
  55. package/dist/shared/typings/commands.d.cts +5 -2
  56. package/dist/shared/typings/commands.d.ts +5 -2
  57. package/dist/shared/typings/components.cjs +0 -15
  58. package/dist/shared/typings/components.cjs.map +1 -1
  59. package/dist/shared/typings/components.d.cts +40 -4
  60. package/dist/shared/typings/components.d.ts +40 -4
  61. package/dist/shared/typings/components.js +1 -14
  62. package/dist/shared/typings/components.js.map +1 -1
  63. package/dist/shared/typings/events.d.cts +4 -1
  64. package/dist/shared/typings/events.d.ts +4 -1
  65. package/dist/shared/typings/index.d.cts +4 -1
  66. package/dist/shared/typings/index.d.ts +4 -1
  67. package/dist/shared/typings/module.d.cts +4 -1
  68. package/dist/shared/typings/module.d.ts +4 -1
  69. package/dist/shared/typings/permissions.cjs +0 -7
  70. package/dist/shared/typings/permissions.cjs.map +1 -1
  71. package/dist/shared/typings/permissions.d.cts +16 -4
  72. package/dist/shared/typings/permissions.d.ts +16 -4
  73. package/dist/shared/typings/permissions.js +1 -7
  74. package/dist/shared/typings/permissions.js.map +1 -1
  75. package/dist/shared/utility/components.utility.cjs +20 -0
  76. package/dist/shared/utility/components.utility.cjs.map +1 -0
  77. package/dist/shared/utility/components.utility.d.cts +19 -0
  78. package/dist/shared/utility/components.utility.d.ts +19 -0
  79. package/dist/shared/utility/components.utility.js +17 -0
  80. package/dist/shared/utility/components.utility.js.map +1 -0
  81. package/dist/shared/utility/functions.cjs +4 -3
  82. package/dist/shared/utility/functions.cjs.map +1 -1
  83. package/dist/shared/utility/functions.d.cts +4 -1
  84. package/dist/shared/utility/functions.d.ts +4 -1
  85. package/dist/shared/utility/functions.js +2 -1
  86. package/dist/shared/utility/functions.js.map +1 -1
  87. package/dist/shared/utility/permissions.utility.cjs +14 -0
  88. package/dist/shared/utility/permissions.utility.cjs.map +1 -0
  89. package/dist/shared/utility/permissions.utility.d.cts +17 -0
  90. package/dist/shared/utility/permissions.utility.d.ts +17 -0
  91. package/dist/shared/utility/permissions.utility.js +12 -0
  92. package/dist/shared/utility/permissions.utility.js.map +1 -0
  93. package/package.json +1 -1
  94. package/dist/core/commands/subcommand.base.cjs +0 -103
  95. package/dist/core/commands/subcommand.base.cjs.map +0 -1
  96. package/dist/core/commands/subcommand.base.d.cts +0 -4
  97. package/dist/core/commands/subcommand.base.d.ts +0 -4
  98. package/dist/core/commands/subcommand.base.js +0 -98
  99. package/dist/core/commands/subcommand.base.js.map +0 -1
  100. package/dist/index-CfL5mpMG.d.ts +0 -879
  101. package/dist/index-DzD1aYla.d.cts +0 -879
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":["ActionRowBuilder","EmbedBuilder"],"mappings":";;;;AAUO,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 { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } 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
+ {"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 +1 @@
1
- {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":[],"mappings":";;AAUO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAI,gBAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AASO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC7B","file":"util.builders.js","sourcesContent":["import { ActionRowBuilder, APIEmbed, EmbedBuilder, EmbedData, MessageActionRowComponentBuilder } 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
+ {"version":3,"sources":["../../../src/core/builders/util.builders.ts"],"names":[],"mappings":";;AAgBO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAI,gBAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AASO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC7B","file":"util.builders.js","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"]}
@@ -5,6 +5,7 @@ var index_js = require('../registry/index.js');
5
5
  var functions_js = require('../../shared/utility/functions.js');
6
6
  var path = require('node:path');
7
7
  var node_fs = require('node:fs');
8
+ var node_crypto = require('node:crypto');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
11
 
@@ -75,10 +76,14 @@ class TriviousClient extends discord_js.Client {
75
76
  const token = process.env[this._options.tokenReference];
76
77
  if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
77
78
  const commands = Array.from(this.registries.commands.get().values());
78
- const body = [...commands.map((command) => command.toJSON())];
79
+ const body = [
80
+ ...commands.map(
81
+ (command) => "data" in command ? command.data.toJSON() : null
82
+ )
83
+ ].filter((c) => c !== null);
79
84
  if (commandHashConfig && commandHashConfig.enabled) {
80
85
  const hashFile = path__default.default.join(commandHashConfig.filePath || "data", "commands.hash");
81
- const newHash = await functions_js.hashCommands(body);
86
+ const newHash = node_crypto.createHash("sha256").update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString()).digest("hex");
82
87
  let oldHash = "";
83
88
  if (await functions_js.exists(hashFile)) oldHash = node_fs.readFileSync(hashFile, "utf-8");
84
89
  if (newHash === oldHash) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","path","hashCommands","exists","readFileSync","existsSync","mkdirSync","writeFileSync","REST","Routes"],"mappings":";;;;;;;;;;;;AAeA,MAAO,uBAAqCA,iBAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAaC,mBAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA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AA,GAAO,IAAIC,eAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,IAAIC,iBAAA,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.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, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\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\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _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 = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\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":["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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oB,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.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,4 +1,7 @@
1
- export { T as default } from '../../index-DzD1aYla.cjs';
1
+ export { T as default } from '../../index-C56Y6_f-.cjs';
2
2
  import 'discord.js';
3
+ import '../../shared/typings/permissions.cjs';
4
+ import '../../shared/typings/client.cjs';
3
5
  import '../../shared/typings/registry.cjs';
6
+ import '../../shared/typings/components.cjs';
4
7
  import '../builders/util.builders.cjs';
@@ -1,4 +1,7 @@
1
- export { T as default } from '../../index-CfL5mpMG.js';
1
+ export { T as default } from '../../index-D9od1fzU.js';
2
2
  import 'discord.js';
3
+ import '../../shared/typings/permissions.js';
4
+ import '../../shared/typings/client.js';
3
5
  import '../../shared/typings/registry.js';
6
+ import '../../shared/typings/components.js';
4
7
  import '../builders/util.builders.js';
@@ -1,8 +1,9 @@
1
1
  import { Client, REST, Routes } from 'discord.js';
2
2
  import { registries } from '../registry/index.js';
3
- import { hashCommands, exists } from '../../shared/utility/functions.js';
3
+ import { exists } from '../../shared/utility/functions.js';
4
4
  import path from 'node:path';
5
5
  import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
6
+ import { createHash } from 'node:crypto';
6
7
 
7
8
  class TriviousClient extends Client {
8
9
  /**
@@ -69,10 +70,14 @@ class TriviousClient extends Client {
69
70
  const token = process.env[this._options.tokenReference];
70
71
  if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
71
72
  const commands = Array.from(this.registries.commands.get().values());
72
- const body = [...commands.map((command) => command.toJSON())];
73
+ const body = [
74
+ ...commands.map(
75
+ (command) => "data" in command ? command.data.toJSON() : null
76
+ )
77
+ ].filter((c) => c !== null);
73
78
  if (commandHashConfig && commandHashConfig.enabled) {
74
79
  const hashFile = path.join(commandHashConfig.filePath || "data", "commands.hash");
75
- const newHash = await hashCommands(body);
80
+ const newHash = createHash("sha256").update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString()).digest("hex");
76
81
  let oldHash = "";
77
82
  if (await exists(hashFile)) oldHash = readFileSync(hashFile, "utf-8");
78
83
  if (newHash === oldHash) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAa,UAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,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,EAA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ACjC;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, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\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\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _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 = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\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":";;;;;;;AAiBA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;A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AG,OAAA,GAAU,YAAA,CAAa,UAAU,OAAO,CAAA;AACpE,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,316 +1,4 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var discord_js = require('discord.js');
6
- var index_js = require('../../shared/typings/index.js');
7
- var functions_js = require('../../shared/utility/functions.js');
8
-
9
- class Command {
10
- data;
11
- metadata;
12
- constructor(builder) {
13
- const { data, metadata } = builder.build();
14
- this.data = data;
15
- this.metadata = metadata;
16
- }
17
- /**
18
- * Returns whether the command is a SlashCommand.
19
- *
20
- * @public
21
- * @param {Command} this
22
- * @returns {this is SlashCommand}
23
- */
24
- isSlashCommand() {
25
- return this instanceof SlashCommand;
26
- }
27
- /**
28
- * Returns whether the command is a ContextMenuCommand.
29
- *
30
- * @public
31
- * @param {Command} this
32
- * @returns {this is ContextMenuCommand}
33
- */
34
- isContextMenuCommand() {
35
- return this instanceof ContextMenuCommand;
36
- }
37
- /**
38
- * Returns JSON of the command builder.
39
- *
40
- * @public
41
- * @returns {*}
42
- */
43
- toJSON() {
44
- return this.data.toJSON();
45
- }
46
- /**
47
- * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
48
- *
49
- * @public
50
- * @async
51
- * @param {CommandInteraction} interaction
52
- * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
53
- * @returns {*}
54
- */
55
- async reply(interaction, options) {
56
- if (interaction.replied || interaction.deferred) {
57
- await interaction.editReply(options);
58
- return;
59
- }
60
- const newOptions = { ...options };
61
- if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
62
- await interaction.reply(newOptions);
63
- }
64
- /**
65
- * Validate permissions for a user/member in a guild.
66
- *
67
- * @async
68
- * @param {CommandInteraction} interaction
69
- * @param {PermissionLevel} permission
70
- * @param {boolean} [doReply=true]
71
- * @returns {unknown}
72
- */
73
- async validateGuildPermission(client, interaction, permission, doReply = true) {
74
- if (!interaction.inGuild()) return true;
75
- const member = interaction.member;
76
- const memberHasPermission = functions_js.hasPermission(client, { permission, member });
77
- if (!memberHasPermission && doReply) {
78
- await this.reply(interaction, {
79
- content: `You do not have permission to run this command, required permission: \`${index_js.PermissionLevel[permission]}\``
80
- });
81
- }
82
- return memberHasPermission;
83
- }
84
- }
85
- class SlashCommand extends Command {
86
- constructor(builder) {
87
- super(builder);
88
- }
89
- /**
90
- * Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
91
- *
92
- * @abstract
93
- */
94
- run;
95
- /**
96
- * General handler for the command and its subcommand, if applicable.
97
- *
98
- * @public
99
- * @async
100
- * @param {TriviousClient} client
101
- * @param {ChatInputCommandInteraction} interaction
102
- * @returns {*}
103
- */
104
- async execute(client, interaction) {
105
- const { metadata } = this;
106
- const { options } = interaction;
107
- if (this.run) {
108
- const hasPerm2 = await this.validateGuildPermission(
109
- client,
110
- interaction,
111
- metadata.permission,
112
- true
113
- );
114
- if (hasPerm2) await this.run(client, interaction);
115
- }
116
- if (!options.getSubcommand(false)) return;
117
- const subcommandName = options.getSubcommand();
118
- const subcommand = metadata.subcommands.get(subcommandName);
119
- if (!subcommand) {
120
- await this.reply(interaction, {
121
- content: "This subcommand no longer exists or is not registered."
122
- });
123
- return;
124
- }
125
- const hasPerm = await this.validateGuildPermission(
126
- client,
127
- interaction,
128
- subcommand.metadata.permission
129
- );
130
- if (!hasPerm) return;
131
- await subcommand.execute(client, interaction);
132
- }
133
- }
134
- class CommandBuilder extends discord_js.SlashCommandBuilder {
135
- _active = true;
136
- _guildOnly = false;
137
- _ownerOnly = false;
138
- _permission = index_js.PermissionLevel.USER;
139
- _subcommands = new discord_js.Collection();
140
- _ephemeralReply = false;
141
- _doProcessReply = false;
142
- doProcessReply(doReply) {
143
- this._doProcessReply = doReply;
144
- return this;
145
- }
146
- /**
147
- * Set the command as disabled.
148
- *
149
- * @public
150
- * @returns {this}
151
- */
152
- disable() {
153
- this._active = false;
154
- return this;
155
- }
156
- /**
157
- * Set the command as guild only.
158
- *
159
- * @public
160
- * @returns {this}
161
- */
162
- setGuildOnly() {
163
- this._guildOnly = true;
164
- this._permission = index_js.PermissionLevel.USER;
165
- this.setContexts(discord_js.InteractionContextType.Guild);
166
- return this;
167
- }
168
- /**
169
- * Set the command as public only.
170
- *
171
- * @public
172
- * @returns {this}
173
- */
174
- setOwnerOnly() {
175
- this._ownerOnly = true;
176
- this._permission = index_js.PermissionLevel.BOT_OWNER;
177
- return this;
178
- }
179
- /**
180
- * Set the permission level required to run the command.
181
- *
182
- * @public
183
- * @param {PermissionLevel} permission
184
- * @returns {this}
185
- */
186
- setPermission(permission) {
187
- if (!this._guildOnly) return this;
188
- this._permission = permission;
189
- return this;
190
- }
191
- /**
192
- * Set the interaction as ephemeral.
193
- *
194
- * @public
195
- * @returns {this}
196
- */
197
- setEphemeralReply() {
198
- this._ephemeralReply = true;
199
- return this;
200
- }
201
- /**
202
- * Build the builder.
203
- *
204
- * @public
205
- * @returns {{ data: CommandBuilder; metadata: CommandMetadata; }}
206
- */
207
- build() {
208
- return {
209
- data: this,
210
- metadata: {
211
- active: this._active,
212
- guildOnly: this._guildOnly,
213
- ownerOnly: this._ownerOnly,
214
- permission: this._permission,
215
- subcommands: this._subcommands,
216
- ephemeralReply: this._ephemeralReply,
217
- doProcessReply: this._doProcessReply
218
- }
219
- };
220
- }
221
- }
222
- class ContextMenuCommand extends Command {
223
- constructor(builder) {
224
- super(builder);
225
- }
226
- /**
227
- * Base command handler.
228
- *
229
- * @public
230
- * @async
231
- * @param {TriviousClient} client
232
- * @param {ContextMenuCommandInteraction} interaction
233
- * @returns {*}
234
- */
235
- async execute(client, interaction) {
236
- const hasPerm = await this.validateGuildPermission(
237
- client,
238
- interaction,
239
- this.metadata.permission
240
- );
241
- if (hasPerm) await this.run(client, interaction);
242
- }
243
- }
244
- class ContextMenuBuilder extends discord_js.ContextMenuCommandBuilder {
245
- _active = true;
246
- _ownerOnly = false;
247
- _permission = index_js.PermissionLevel.USER;
248
- _ephemeralReply = false;
249
- /**
250
- * Set the command as disabled.
251
- *
252
- * @public
253
- * @returns {this}
254
- */
255
- disable() {
256
- this._active = false;
257
- return this;
258
- }
259
- /**
260
- * Set the command as owner only.
261
- *
262
- * @public
263
- * @returns {this}
264
- */
265
- setOwnerOnly() {
266
- this._permission = index_js.PermissionLevel.BOT_OWNER;
267
- this._ownerOnly = true;
268
- return this;
269
- }
270
- /**
271
- * Set the permission level required to run the command.
272
- *
273
- * @public
274
- * @param {PermissionLevel} permission
275
- * @returns {this}
276
- */
277
- setPermission(permission) {
278
- this._permission = permission;
279
- return this;
280
- }
281
- /**
282
- * Set the interaction as ephemeral.
283
- *
284
- * @public
285
- * @returns {this}
286
- */
287
- setEphemeralReply() {
288
- this._ephemeralReply = true;
289
- return this;
290
- }
291
- /**
292
- * Build the builder
293
- *
294
- * @public
295
- * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
296
- */
297
- build() {
298
- return {
299
- data: this,
300
- metadata: {
301
- active: this._active,
302
- ownerOnly: this._ownerOnly,
303
- permission: this._permission,
304
- ephemeralReply: this._ephemeralReply
305
- }
306
- };
307
- }
308
- }
309
-
310
- exports.CommandBuilder = CommandBuilder;
311
- exports.ContextMenuBuilder = ContextMenuBuilder;
312
- exports.ContextMenuCommand = ContextMenuCommand;
313
- exports.SlashCommand = SlashCommand;
314
- exports.default = Command;
315
3
  //# sourceMappingURL=command.base.cjs.map
316
4
  //# sourceMappingURL=command.base.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/commands/command.base.ts"],"names":["hasPermission","PermissionLevel","hasPerm","SlashCommandBuilder","Collection","InteractionContextType","ContextMenuCommandBuilder"],"mappings":";;;;;;;;AAkCA,MAAO,OAAA,CAA+B;AAAA,EACrB,IAAA;AAAA,EACA,QAAA;AAAA,EAEN,YAAY,OAAA,EAA4B;AACjD,IAAA,MAAM,EAAE,IAAA,EAAM,QAAA,EAAS,GAAI,QAAQ,KAAA,EAAM;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,cAAA,GAAoD;AAC1D,IAAA,OAAO,IAAA,YAAgB,YAAA;AAAA,EACxB;AAA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A,CAAK,OAAA,GAAU,KAAA;AACf,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,YAAA,GAAqB;AAC3B,IAAA,IAAA,CAAK,cAAcA,wBAAA,CAAgB,SAAA;AACnC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAClB,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,cAAc,UAAA,EAAmC;AACvD,IAAA,IAAA,CAAK,WAAA,GAAc,UAAA;AACnB,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,iBAAA,GAA0B;AAChC,IAAA,IAAA,CAAK,eAAA,GAAkB,IAAA;AACvB,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,KAAA,GAAQ;AACd,IAAA,OAAO;AAAA,MACN,IAAA,EAAM,IAAA;AAAA,MACN,QAAA,EAAU;AAAA,QACT,QAAQ,IAAA,CAAK,OAAA;AAAA,QACb,WAAW,IAAA,CAAK,UAAA;AAAA,QAChB,YAAY,IAAA,CAAK,WAAA;AAAA,QACjB,gBAAgB,IAAA,CAAK;AAAA;AACtB,KACD;AAAA,EACD;AACD","file":"command.base.cjs","sourcesContent":["import {\n\tCollection,\n\tContextMenuCommandBuilder,\n\tGuildMember,\n\tInteractionContextType,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tMessagePayload,\n\tSlashCommandBuilder,\n} from \"discord.js\";\nimport {\n\tAnyCommandBuilder,\n\tAnyCommandMetadata,\n\tCommandInteraction,\n\tCommandMetadata,\n\tContextMenuMetadata,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport {\n\tChatInputCommandInteraction,\n\tContextMenuCommandInteraction,\n\tSubcommand,\n} from \"src/index.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\n\n/**\n * Base class for a Command.\n *\n * @export\n * @abstract\n * @class Command\n * @typedef {Command}\n */\nexport default abstract class Command {\n\tpublic readonly data: SlashCommandBuilder | ContextMenuCommandBuilder;\n\tpublic readonly metadata: AnyCommandMetadata;\n\n\tprotected constructor(builder: AnyCommandBuilder) {\n\t\tconst { data, metadata } = builder.build();\n\t\tthis.data = data;\n\t\tthis.metadata = metadata;\n\t}\n\n\t/**\n\t * Returns whether the command is a SlashCommand.\n\t *\n\t * @public\n\t * @param {Command} this\n\t * @returns {this is SlashCommand}\n\t */\n\tpublic isSlashCommand(this: Command): this is SlashCommand {\n\t\treturn this instanceof SlashCommand;\n\t}\n\n\t/**\n\t * Returns whether the command is a ContextMenuCommand.\n\t *\n\t * @public\n\t * @param {Command} this\n\t * @returns {this is ContextMenuCommand}\n\t */\n\tpublic isContextMenuCommand(this: Command): this is ContextMenuCommand {\n\t\treturn this instanceof ContextMenuCommand;\n\t}\n\n\t/**\n\t * Returns JSON of the command builder.\n\t *\n\t * @public\n\t * @returns {*}\n\t */\n\tpublic toJSON() {\n\t\treturn this.data.toJSON();\n\t}\n\n\t/**\n\t * Reply to the interaction respecting command metadata and if the interaction has already been replied to.\n\t *\n\t * @public\n\t * @async\n\t * @param {CommandInteraction} interaction\n\t * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options\n\t * @returns {*}\n\t */\n\tpublic async reply(\n\t\tinteraction: CommandInteraction,\n\t\toptions: MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions\n\t) {\n\t\tif (interaction.replied || interaction.deferred) {\n\t\t\tawait interaction.editReply(options as InteractionEditReplyOptions);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newOptions = { ...options } as InteractionReplyOptions;\n\t\tif (this.metadata.ephemeralReply) newOptions.flags = [\"Ephemeral\"];\n\n\t\tawait interaction.reply(newOptions);\n\t}\n\n\t/**\n\t * Validate permissions for a user/member in a guild.\n\t *\n\t * @async\n\t * @param {CommandInteraction} interaction\n\t * @param {PermissionLevel} permission\n\t * @param {boolean} [doReply=true]\n\t * @returns {unknown}\n\t */\n\tasync validateGuildPermission(\n\t\tclient: TriviousClient,\n\t\tinteraction: CommandInteraction,\n\t\tpermission: PermissionLevel,\n\t\tdoReply: boolean = true\n\t) {\n\t\tif (!interaction.inGuild()) return true;\n\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\n\t\tif (!memberHasPermission && doReply) {\n\t\t\tawait this.reply(interaction, {\n\t\t\t\tcontent: `You do not have permission to run this command, required permission: \\`${PermissionLevel[permission]}\\``,\n\t\t\t});\n\t\t}\n\n\t\treturn memberHasPermission;\n\t}\n}\n\n/**\n * Base SlashCommand.\n *\n * @export\n * @abstract\n * @class SlashCommand\n * @typedef {SlashCommand}\n * @extends {Command}\n */\nexport abstract class SlashCommand extends Command {\n\tdeclare public readonly data: SlashCommandBuilder;\n\tdeclare public readonly metadata: CommandMetadata;\n\n\tprotected constructor(builder: CommandBuilder) {\n\t\tsuper(builder);\n\t}\n\n\t/**\n\t * Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.\n\t *\n\t * @abstract\n\t */\n\trun?: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;\n\n\t/**\n\t * General handler for the command and its subcommand, if applicable.\n\t *\n\t * @public\n\t * @async\n\t * @param {TriviousClient} client\n\t * @param {ChatInputCommandInteraction} interaction\n\t * @returns {*}\n\t */\n\tpublic async execute(client: TriviousClient, interaction: ChatInputCommandInteraction) {\n\t\tconst { metadata } = this;\n\t\tconst { options } = interaction;\n\n\t\tif (this.run) {\n\t\t\tconst hasPerm = await this.validateGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tmetadata.permission,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tif (hasPerm) await this.run(client, interaction);\n\t\t}\n\n\t\tif (!options.getSubcommand(false)) return;\n\n\t\tconst subcommandName = options.getSubcommand();\n\t\tconst subcommand = metadata.subcommands.get(subcommandName);\n\n\t\tif (!subcommand) {\n\t\t\tawait this.reply(interaction, {\n\t\t\t\tcontent: \"This subcommand no longer exists or is not registered.\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasPerm = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tsubcommand.metadata.permission\n\t\t);\n\t\tif (!hasPerm) return;\n\n\t\tawait subcommand.execute(client, interaction);\n\t}\n}\n\n/**\n * Base CommandBuilder.\n *\n * @export\n * @class CommandBuilder\n * @typedef {CommandBuilder}\n * @extends {SlashCommandBuilder}\n */\nexport class CommandBuilder extends SlashCommandBuilder {\n\tprivate _active = true;\n\tprivate _guildOnly = false;\n\tprivate _ownerOnly = false;\n\tprivate _permission = PermissionLevel.USER;\n\tprivate _subcommands = new Collection<string, Subcommand>();\n\tprivate _ephemeralReply = false;\n\tprivate _doProcessReply = false;\n\n\tpublic doProcessReply(doReply: boolean): this {\n\t\tthis._doProcessReply = doReply;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the command as disabled.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic disable(): this {\n\t\tthis._active = false;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the command as guild only.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic setGuildOnly(): this {\n\t\tthis._guildOnly = true;\n\t\tthis._permission = PermissionLevel.USER;\n\t\tthis.setContexts(InteractionContextType.Guild);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the command as public only.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic setOwnerOnly(): this {\n\t\tthis._ownerOnly = true;\n\t\tthis._permission = PermissionLevel.BOT_OWNER;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the permission level required to run the command.\n\t *\n\t * @public\n\t * @param {PermissionLevel} permission\n\t * @returns {this}\n\t */\n\tpublic setPermission(permission: PermissionLevel): this {\n\t\tif (!this._guildOnly) return this;\n\t\tthis._permission = permission;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the interaction as ephemeral.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic setEphemeralReply(): this {\n\t\tthis._ephemeralReply = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Build the builder.\n\t *\n\t * @public\n\t * @returns {{ data: CommandBuilder; metadata: CommandMetadata; }}\n\t */\n\tpublic build() {\n\t\treturn {\n\t\t\tdata: this as CommandBuilder,\n\t\t\tmetadata: {\n\t\t\t\tactive: this._active,\n\t\t\t\tguildOnly: this._guildOnly,\n\t\t\t\townerOnly: this._ownerOnly,\n\t\t\t\tpermission: this._permission,\n\t\t\t\tsubcommands: this._subcommands,\n\t\t\t\tephemeralReply: this._ephemeralReply,\n\t\t\t\tdoProcessReply: this._doProcessReply,\n\t\t\t} satisfies CommandMetadata,\n\t\t};\n\t}\n}\n\n/**\n * Base ContextMenuCommand.\n *\n * @export\n * @abstract\n * @class ContextMenuCommand\n * @typedef {ContextMenuCommand}\n * @extends {Command}\n */\nexport abstract class ContextMenuCommand extends Command {\n\tdeclare public readonly data: ContextMenuCommandBuilder;\n\tdeclare public readonly metadata: ContextMenuMetadata;\n\n\tprotected constructor(builder: ContextMenuBuilder) {\n\t\tsuper(builder);\n\t}\n\n\t/**\n\t * Function to run when the command is used.\n\t *\n\t * @abstract\n\t */\n\tabstract run: (\n\t\tclient: TriviousClient,\n\t\tinteraction: ContextMenuCommandInteraction\n\t) => Promise<void>;\n\n\t/**\n\t * Base command handler.\n\t *\n\t * @public\n\t * @async\n\t * @param {TriviousClient} client\n\t * @param {ContextMenuCommandInteraction} interaction\n\t * @returns {*}\n\t */\n\tpublic async execute(client: TriviousClient, interaction: ContextMenuCommandInteraction) {\n\t\tconst hasPerm = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tthis.metadata.permission\n\t\t);\n\t\tif (hasPerm) await this.run(client, interaction);\n\t}\n}\n\n/**\n * Base ContextMenuBuilder.\n *\n * @export\n * @class ContextMenuBuilder\n * @typedef {ContextMenuBuilder}\n * @extends {ContextMenuCommandBuilder}\n */\nexport class ContextMenuBuilder extends ContextMenuCommandBuilder {\n\tprivate _active = true;\n\tprivate _ownerOnly = false;\n\tprivate _permission = PermissionLevel.USER;\n\tprivate _ephemeralReply = false;\n\n\t/**\n\t * Set the command as disabled.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic disable(): this {\n\t\tthis._active = false;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the command as owner only.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic setOwnerOnly(): this {\n\t\tthis._permission = PermissionLevel.BOT_OWNER;\n\t\tthis._ownerOnly = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the permission level required to run the command.\n\t *\n\t * @public\n\t * @param {PermissionLevel} permission\n\t * @returns {this}\n\t */\n\tpublic setPermission(permission: PermissionLevel): this {\n\t\tthis._permission = permission;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the interaction as ephemeral.\n\t *\n\t * @public\n\t * @returns {this}\n\t */\n\tpublic setEphemeralReply(): this {\n\t\tthis._ephemeralReply = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Build the builder\n\t *\n\t * @public\n\t * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}\n\t */\n\tpublic build() {\n\t\treturn {\n\t\t\tdata: this as ContextMenuBuilder,\n\t\t\tmetadata: {\n\t\t\t\tactive: this._active,\n\t\t\t\townerOnly: this._ownerOnly,\n\t\t\t\tpermission: this._permission,\n\t\t\t\tephemeralReply: this._ephemeralReply,\n\t\t\t} satisfies ContextMenuMetadata,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"command.base.cjs"}
@@ -1,4 +1,7 @@
1
+ import '../../shared/typings/permissions.cjs';
1
2
  import 'discord.js';
2
- export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-DzD1aYla.cjs';
3
+ export { C as Command, l as ContextMenuCommand, S as SlashCommand, k as SlashSubcommand } from '../../index-C56Y6_f-.cjs';
3
4
  import '../../shared/typings/registry.cjs';
5
+ import '../../shared/typings/components.cjs';
6
+ import '../../shared/typings/client.cjs';
4
7
  import '../builders/util.builders.cjs';
@@ -1,4 +1,7 @@
1
+ import '../../shared/typings/permissions.js';
1
2
  import 'discord.js';
2
- export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-CfL5mpMG.js';
3
+ export { C as Command, l as ContextMenuCommand, S as SlashCommand, k as SlashSubcommand } from '../../index-D9od1fzU.js';
3
4
  import '../../shared/typings/registry.js';
5
+ import '../../shared/typings/components.js';
6
+ import '../../shared/typings/client.js';
4
7
  import '../builders/util.builders.js';