trivious 1.4.3 → 1.5.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.
- package/dist/core/client/trivious.client.cjs.map +1 -1
- package/dist/core/client/trivious.client.d.cts +1 -1
- package/dist/core/client/trivious.client.d.ts +1 -1
- package/dist/core/client/trivious.client.js.map +1 -1
- package/dist/core/commands/command.base.cjs +39 -34
- package/dist/core/commands/command.base.cjs.map +1 -1
- package/dist/core/commands/command.base.d.cts +1 -1
- package/dist/core/commands/command.base.d.ts +1 -1
- package/dist/core/commands/command.base.js +40 -35
- package/dist/core/commands/command.base.js.map +1 -1
- package/dist/core/commands/subcommand.base.cjs +8 -1
- package/dist/core/commands/subcommand.base.cjs.map +1 -1
- package/dist/core/commands/subcommand.base.d.cts +1 -1
- package/dist/core/commands/subcommand.base.d.ts +1 -1
- package/dist/core/commands/subcommand.base.js +8 -1
- package/dist/core/commands/subcommand.base.js.map +1 -1
- package/dist/core/components/component.base.d.cts +1 -1
- package/dist/core/components/component.base.d.ts +1 -1
- package/dist/core/events/clientReady.d.cts +1 -1
- package/dist/core/events/clientReady.d.ts +1 -1
- package/dist/core/events/interactionCreate.d.cts +1 -1
- package/dist/core/events/interactionCreate.d.ts +1 -1
- package/dist/core/registry/command.registry.d.cts +1 -1
- package/dist/core/registry/command.registry.d.ts +1 -1
- package/dist/core/registry/component.registry.d.cts +1 -1
- package/dist/core/registry/component.registry.d.ts +1 -1
- package/dist/core/registry/event.registry.d.cts +1 -1
- package/dist/core/registry/event.registry.d.ts +1 -1
- package/dist/core/registry/index.d.cts +1 -1
- package/dist/core/registry/index.d.ts +1 -1
- package/dist/core/registry/module.registry.d.cts +1 -1
- package/dist/core/registry/module.registry.d.ts +1 -1
- package/dist/{index-BdQvQiVi.d.ts → index-Bf8pz7za.d.ts} +16 -18
- package/dist/{index-DIZ3Scja.d.cts → index-DQ3Y6DvJ.d.cts} +16 -18
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared/typings/client.d.cts +1 -1
- package/dist/shared/typings/client.d.ts +1 -1
- package/dist/shared/typings/commands.d.cts +1 -1
- package/dist/shared/typings/commands.d.ts +1 -1
- package/dist/shared/typings/components.d.cts +1 -1
- package/dist/shared/typings/components.d.ts +1 -1
- package/dist/shared/typings/events.d.cts +1 -1
- package/dist/shared/typings/events.d.ts +1 -1
- package/dist/shared/typings/index.d.cts +1 -1
- package/dist/shared/typings/index.d.ts +1 -1
- package/dist/shared/typings/module.d.cts +1 -1
- package/dist/shared/typings/module.d.ts +1 -1
- package/dist/shared/typings/permissions.d.cts +1 -1
- package/dist/shared/typings/permissions.d.ts +1 -1
- package/dist/shared/utility/functions.d.cts +1 -1
- package/dist/shared/utility/functions.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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;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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;AACnE,IAAA,MAAM,IAAA,GAAO,CAAC,GAAG,QAAA,CAAS,IAAI,CAAA,OAAA,KAAW,OAAA,CAAQ,MAAA,EAAQ,CAAC,CAAA;AAE1D,IAAA,IAAI,iBAAA,IAAqB,kBAAkB,OAAA,EAAS;AACnD,MAAA,MAAM,WAAWC,qBAAA,CAAK,IAAA,CAAK,iBAAA,CAAkB,QAAA,IAAY,QAAQ,eAAe,CAAA;AAChF,MAAA,MAAM,OAAA,GAAU,MAAMC,yBAAA,CAAa,IAAI,CAAA;AACvC,MAAA,IAAI,OAAA,GAAU,EAAA;AAEd,MAAA,IAAI,MAAMC,mBAAA,CAAO,QAAQ,GAAG,OAAA,GAAUC,oBAAA,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,GAAgBH,qBAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAC3C,MAAA,IAAI,CAACI,kBAAA,CAAW,aAAa,CAAA,EAAG;AAC/B,QAAAC,iBAAA,CAAU,aAAA,EAAe,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAAA,MAC7C;AAEA,MAAAC,qBAAA,CAAc,QAAA,EAAU,OAAA,EAAS,EAAE,QAAA,EAAU,
|
|
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,EA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D,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,qCAAA,EAAwC,QAAQ,CAAA,CAAE,CAAA;AAAA,IACjE;AAEA,IAAA,MAAM,IAAA,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 +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,C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O,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, 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"]}
|
|
@@ -7,6 +7,13 @@ var index_js = require('../../shared/typings/index.js');
|
|
|
7
7
|
var functions_js = require('../../shared/utility/functions.js');
|
|
8
8
|
|
|
9
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
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* Returns whether the command is a SlashCommand.
|
|
12
19
|
*
|
|
@@ -15,7 +22,7 @@ class Command {
|
|
|
15
22
|
* @returns {this is SlashCommand}
|
|
16
23
|
*/
|
|
17
24
|
isSlashCommand() {
|
|
18
|
-
return this
|
|
25
|
+
return this instanceof SlashCommand;
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -25,7 +32,7 @@ class Command {
|
|
|
25
32
|
* @returns {this is ContextMenuCommand}
|
|
26
33
|
*/
|
|
27
34
|
isContextMenuCommand() {
|
|
28
|
-
return this
|
|
35
|
+
return this instanceof ContextMenuCommand;
|
|
29
36
|
}
|
|
30
37
|
/**
|
|
31
38
|
* Returns JSON of the command builder.
|
|
@@ -46,7 +53,7 @@ class Command {
|
|
|
46
53
|
* @returns {*}
|
|
47
54
|
*/
|
|
48
55
|
async reply(interaction, options) {
|
|
49
|
-
if (interaction.replied) {
|
|
56
|
+
if (interaction.replied || interaction.deferred) {
|
|
50
57
|
await interaction.editReply(options);
|
|
51
58
|
return;
|
|
52
59
|
}
|
|
@@ -64,10 +71,7 @@ class Command {
|
|
|
64
71
|
* @returns {unknown}
|
|
65
72
|
*/
|
|
66
73
|
async validateGuildPermission(client, interaction, permission, doReply = true) {
|
|
67
|
-
|
|
68
|
-
const isChatInput = interaction.isChatInputCommand();
|
|
69
|
-
const requiresGuildCheck = isContextMenu || isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false);
|
|
70
|
-
if (!requiresGuildCheck) return true;
|
|
74
|
+
if (!interaction.inGuild()) return true;
|
|
71
75
|
const member = interaction.member;
|
|
72
76
|
const memberHasPermission = functions_js.hasPermission(client, { permission, member });
|
|
73
77
|
if (!memberHasPermission && doReply) {
|
|
@@ -79,14 +83,13 @@ class Command {
|
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
class SlashCommand extends Command {
|
|
86
|
+
constructor(builder) {
|
|
87
|
+
super(builder);
|
|
88
|
+
}
|
|
82
89
|
/**
|
|
83
90
|
* Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
|
|
84
91
|
*
|
|
85
92
|
* @abstract
|
|
86
|
-
* @type {?(
|
|
87
|
-
* client: TriviousClient,
|
|
88
|
-
* interaction: ChatInputCommandInteraction
|
|
89
|
-
* ) => Promise<void>}
|
|
90
93
|
*/
|
|
91
94
|
run;
|
|
92
95
|
/**
|
|
@@ -99,34 +102,34 @@ class SlashCommand extends Command {
|
|
|
99
102
|
* @returns {*}
|
|
100
103
|
*/
|
|
101
104
|
async execute(client, interaction) {
|
|
102
|
-
const {
|
|
105
|
+
const { metadata } = this;
|
|
103
106
|
const { options } = interaction;
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
if (!options.getSubcommand(false)) {
|
|
108
|
+
if (this.run) {
|
|
109
|
+
const hasPerm2 = await this.validateGuildPermission(
|
|
110
|
+
client,
|
|
111
|
+
interaction,
|
|
112
|
+
metadata.permission,
|
|
113
|
+
false
|
|
114
|
+
);
|
|
115
|
+
if (hasPerm2) await this.run(client, interaction);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
112
118
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const subcommand = metadata.subcommands.find(
|
|
116
|
-
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
117
|
-
);
|
|
119
|
+
const subcommandName = options.getSubcommand();
|
|
120
|
+
const subcommand = metadata.subcommands.get(subcommandName);
|
|
118
121
|
if (!subcommand) {
|
|
119
|
-
await reply(interaction, {
|
|
120
|
-
content: "
|
|
122
|
+
await this.reply(interaction, {
|
|
123
|
+
content: "This subcommand no longer exists or is not registered."
|
|
121
124
|
});
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
|
-
const
|
|
127
|
+
const hasPerm = await this.validateGuildPermission(
|
|
125
128
|
client,
|
|
126
129
|
interaction,
|
|
127
130
|
subcommand.metadata.permission
|
|
128
131
|
);
|
|
129
|
-
if (!
|
|
132
|
+
if (!hasPerm) return;
|
|
130
133
|
await subcommand.execute(client, interaction);
|
|
131
134
|
}
|
|
132
135
|
}
|
|
@@ -166,6 +169,7 @@ class CommandBuilder extends discord_js.SlashCommandBuilder {
|
|
|
166
169
|
* @returns {this}
|
|
167
170
|
*/
|
|
168
171
|
setOwnerOnly() {
|
|
172
|
+
this._ownerOnly = true;
|
|
169
173
|
this._permission = index_js.PermissionLevel.BOT_OWNER;
|
|
170
174
|
return this;
|
|
171
175
|
}
|
|
@@ -212,6 +216,9 @@ class CommandBuilder extends discord_js.SlashCommandBuilder {
|
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
218
|
class ContextMenuCommand extends Command {
|
|
219
|
+
constructor(builder) {
|
|
220
|
+
super(builder);
|
|
221
|
+
}
|
|
215
222
|
/**
|
|
216
223
|
* Base command handler.
|
|
217
224
|
*
|
|
@@ -222,14 +229,12 @@ class ContextMenuCommand extends Command {
|
|
|
222
229
|
* @returns {*}
|
|
223
230
|
*/
|
|
224
231
|
async execute(client, interaction) {
|
|
225
|
-
const
|
|
226
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
232
|
+
const hasPerm = await this.validateGuildPermission(
|
|
227
233
|
client,
|
|
228
234
|
interaction,
|
|
229
|
-
metadata.permission
|
|
230
|
-
false
|
|
235
|
+
this.metadata.permission
|
|
231
236
|
);
|
|
232
|
-
if (
|
|
237
|
+
if (hasPerm) await this.run(client, interaction);
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
class ContextMenuBuilder extends discord_js.ContextMenuCommandBuilder {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/commands/command.base.ts"],"names":["SlashCommandBuilder","ContextMenuCommandBuilder","hasPermission","PermissionLevel","memberHasPermission","Collection","InteractionContextType"],"mappings":";;;;;;;;AAgCA,MAAO,OAAA,CAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW9B,cAAA,GAAoD;AAC1D,IAAA,OAAO,IAAA,CAAK,IAAA,YAAgBA,8BAAA,IAAuB,IAAA,YAAgB,YAAA;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,oBAAA,GAAgE;AACtE,IAAA,OAAO,IAAA,CAAK,IAAA,YAAgBC,oCAAA,IAA6B,IAAA,YAAgB,kBAAA;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,MAAA,GAAS;AACf,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,EAAO;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,KAAA,CACZ,WAAA,EACA,OAAA,EACC;AACD,IAAA,IAAI,YAAY,OAAA,EAAS;AACxB,MAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,MAAA;AAAA,IACD;AAEA,IAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,IAAA,IAAI,KAAK,QAAA,CAAS,cAAA,EAAgB,UAAA,CAAW,KAAA,GAAQ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,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\tCommandInteraction,\n\tCommandMetadata,\n\tContextMenuMetadata,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport {\n\tChatInputCommandInteraction,\n\tContextMenuCommandInteraction,\n\tSubcommand,\n} from \"src/index.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\tabstract data: SlashCommandBuilder | ContextMenuCommandBuilder;\n\tabstract metadata: CommandMetadata | ContextMenuMetadata;\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.data instanceof SlashCommandBuilder && 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.data instanceof ContextMenuCommandBuilder && 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) {\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\tconst isContextMenu = interaction.isContextMenuCommand();\n\t\tconst isChatInput = interaction.isChatInputCommand();\n\n\t\tconst requiresGuildCheck =\n\t\t\tisContextMenu || (isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false));\n\t\tif (!requiresGuildCheck) 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\tabstract data: SlashCommandBuilder;\n\tabstract metadata: CommandMetadata;\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 * @type {?(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ChatInputCommandInteraction\n\t * \t) => Promise<void>}\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 { run, reply, metadata } = this;\n\t\tconst { options } = interaction;\n\n\t\tif (run) {\n\t\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tmetadata.permission,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif (memberHasPermission) await run(client, interaction);\n\t\t}\n\n\t\tconst subcommands = metadata.subcommands;\n\t\tif (subcommands.size <= 0) return;\n\n\t\tconst subcommand = metadata.subcommands.find(\n\t\t\tsubcmd => subcmd.data.name === options.getSubcommand()\n\t\t);\n\t\tif (!subcommand) {\n\t\t\tawait reply(interaction, {\n\t\t\t\tcontent: \"Ran subcommand is outdated or does not have a handler!\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tsubcommand.metadata.permission\n\t\t);\n\t\tif (!memberHasPermission) 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\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._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\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: 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} 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\tabstract data: ContextMenuCommandBuilder;\n\tabstract metadata: ContextMenuMetadata;\n\t/**\n\t * Function to run when the command is used.\n\t *\n\t * @abstract\n\t * @type {(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ContextMenuCommandInteraction\n\t * \t) => Promise<void>}\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 { run, metadata } = this;\n\n\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tmetadata.permission,\n\t\t\tfalse\n\t\t);\n\t\tif (memberHasPermission) await 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":["../../../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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,oBAAA,GAAgE;AACtE,IAAA,OAAO,IAAA,YAAgB,kBAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,MAAA,GAAS;AACf,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,E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,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 (!options.getSubcommand(false)) {\n\t\t\tif (this.run) {\n\t\t\t\tconst hasPerm = await this.validateGuildPermission(\n\t\t\t\t\tclient,\n\t\t\t\t\tinteraction,\n\t\t\t\t\tmetadata.permission,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif (hasPerm) await this.run(client, interaction);\n\t\t\t}\n\t\t\treturn;\n\t\t}\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\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} 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,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-DQ3Y6DvJ.cjs';
|
|
3
3
|
import '../../shared/typings/registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-Bf8pz7za.js';
|
|
3
3
|
import '../../shared/typings/registry.js';
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { SlashCommandBuilder,
|
|
1
|
+
import { SlashCommandBuilder, Collection, InteractionContextType, ContextMenuCommandBuilder } from 'discord.js';
|
|
2
2
|
import { PermissionLevel } from '../../shared/typings/index.js';
|
|
3
3
|
import { hasPermission } from '../../shared/utility/functions.js';
|
|
4
4
|
|
|
5
5
|
class Command {
|
|
6
|
+
data;
|
|
7
|
+
metadata;
|
|
8
|
+
constructor(builder) {
|
|
9
|
+
const { data, metadata } = builder.build();
|
|
10
|
+
this.data = data;
|
|
11
|
+
this.metadata = metadata;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* Returns whether the command is a SlashCommand.
|
|
8
15
|
*
|
|
@@ -11,7 +18,7 @@ class Command {
|
|
|
11
18
|
* @returns {this is SlashCommand}
|
|
12
19
|
*/
|
|
13
20
|
isSlashCommand() {
|
|
14
|
-
return this
|
|
21
|
+
return this instanceof SlashCommand;
|
|
15
22
|
}
|
|
16
23
|
/**
|
|
17
24
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -21,7 +28,7 @@ class Command {
|
|
|
21
28
|
* @returns {this is ContextMenuCommand}
|
|
22
29
|
*/
|
|
23
30
|
isContextMenuCommand() {
|
|
24
|
-
return this
|
|
31
|
+
return this instanceof ContextMenuCommand;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Returns JSON of the command builder.
|
|
@@ -42,7 +49,7 @@ class Command {
|
|
|
42
49
|
* @returns {*}
|
|
43
50
|
*/
|
|
44
51
|
async reply(interaction, options) {
|
|
45
|
-
if (interaction.replied) {
|
|
52
|
+
if (interaction.replied || interaction.deferred) {
|
|
46
53
|
await interaction.editReply(options);
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
@@ -60,10 +67,7 @@ class Command {
|
|
|
60
67
|
* @returns {unknown}
|
|
61
68
|
*/
|
|
62
69
|
async validateGuildPermission(client, interaction, permission, doReply = true) {
|
|
63
|
-
|
|
64
|
-
const isChatInput = interaction.isChatInputCommand();
|
|
65
|
-
const requiresGuildCheck = isContextMenu || isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false);
|
|
66
|
-
if (!requiresGuildCheck) return true;
|
|
70
|
+
if (!interaction.inGuild()) return true;
|
|
67
71
|
const member = interaction.member;
|
|
68
72
|
const memberHasPermission = hasPermission(client, { permission, member });
|
|
69
73
|
if (!memberHasPermission && doReply) {
|
|
@@ -75,14 +79,13 @@ class Command {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
class SlashCommand extends Command {
|
|
82
|
+
constructor(builder) {
|
|
83
|
+
super(builder);
|
|
84
|
+
}
|
|
78
85
|
/**
|
|
79
86
|
* Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
|
|
80
87
|
*
|
|
81
88
|
* @abstract
|
|
82
|
-
* @type {?(
|
|
83
|
-
* client: TriviousClient,
|
|
84
|
-
* interaction: ChatInputCommandInteraction
|
|
85
|
-
* ) => Promise<void>}
|
|
86
89
|
*/
|
|
87
90
|
run;
|
|
88
91
|
/**
|
|
@@ -95,34 +98,34 @@ class SlashCommand extends Command {
|
|
|
95
98
|
* @returns {*}
|
|
96
99
|
*/
|
|
97
100
|
async execute(client, interaction) {
|
|
98
|
-
const {
|
|
101
|
+
const { metadata } = this;
|
|
99
102
|
const { options } = interaction;
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
if (!options.getSubcommand(false)) {
|
|
104
|
+
if (this.run) {
|
|
105
|
+
const hasPerm2 = await this.validateGuildPermission(
|
|
106
|
+
client,
|
|
107
|
+
interaction,
|
|
108
|
+
metadata.permission,
|
|
109
|
+
false
|
|
110
|
+
);
|
|
111
|
+
if (hasPerm2) await this.run(client, interaction);
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
108
114
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const subcommand = metadata.subcommands.find(
|
|
112
|
-
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
113
|
-
);
|
|
115
|
+
const subcommandName = options.getSubcommand();
|
|
116
|
+
const subcommand = metadata.subcommands.get(subcommandName);
|
|
114
117
|
if (!subcommand) {
|
|
115
|
-
await reply(interaction, {
|
|
116
|
-
content: "
|
|
118
|
+
await this.reply(interaction, {
|
|
119
|
+
content: "This subcommand no longer exists or is not registered."
|
|
117
120
|
});
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
|
-
const
|
|
123
|
+
const hasPerm = await this.validateGuildPermission(
|
|
121
124
|
client,
|
|
122
125
|
interaction,
|
|
123
126
|
subcommand.metadata.permission
|
|
124
127
|
);
|
|
125
|
-
if (!
|
|
128
|
+
if (!hasPerm) return;
|
|
126
129
|
await subcommand.execute(client, interaction);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
@@ -162,6 +165,7 @@ class CommandBuilder extends SlashCommandBuilder {
|
|
|
162
165
|
* @returns {this}
|
|
163
166
|
*/
|
|
164
167
|
setOwnerOnly() {
|
|
168
|
+
this._ownerOnly = true;
|
|
165
169
|
this._permission = PermissionLevel.BOT_OWNER;
|
|
166
170
|
return this;
|
|
167
171
|
}
|
|
@@ -208,6 +212,9 @@ class CommandBuilder extends SlashCommandBuilder {
|
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
class ContextMenuCommand extends Command {
|
|
215
|
+
constructor(builder) {
|
|
216
|
+
super(builder);
|
|
217
|
+
}
|
|
211
218
|
/**
|
|
212
219
|
* Base command handler.
|
|
213
220
|
*
|
|
@@ -218,14 +225,12 @@ class ContextMenuCommand extends Command {
|
|
|
218
225
|
* @returns {*}
|
|
219
226
|
*/
|
|
220
227
|
async execute(client, interaction) {
|
|
221
|
-
const
|
|
222
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
228
|
+
const hasPerm = await this.validateGuildPermission(
|
|
223
229
|
client,
|
|
224
230
|
interaction,
|
|
225
|
-
metadata.permission
|
|
226
|
-
false
|
|
231
|
+
this.metadata.permission
|
|
227
232
|
);
|
|
228
|
-
if (
|
|
233
|
+
if (hasPerm) await this.run(client, interaction);
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
236
|
class ContextMenuBuilder extends ContextMenuCommandBuilder {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/commands/command.base.ts"],"names":["memberHasPermission"],"mappings":";;;;AAgCA,MAAO,OAAA,CAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW9B,cAAA,GAAoD;AAC1D,IAAA,OAAO,IAAA,CAAK,IAAA,YAAgB,mBAAA,IAAuB,IAAA,YAAgB,YAAA;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,oBAAA,GAAgE;AACtE,IAAA,OAAO,IAAA,CAAK,IAAA,YAAgB,yBAAA,IAA6B,IAAA,YAAgB,kBAAA;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,MAAA,GAAS;AACf,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,EAAO;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,KAAA,CACZ,WAAA,EACA,OAAA,EACC;AACD,IAAA,IAAI,YAAY,OAAA,EAAS;AACxB,MAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,MAAA;AAAA,IACD;AAEA,IAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,IAAA,IAAI,KAAK,QAAA,CAAS,cAAA,EAAgB,UAAA,CAAW,KAAA,GAAQ,CAAC,WAAW,CAAA;AAEjE,IAAA,MAAM,WAAA,CAAY,MAAM,UAAU,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,uBAAA,CACL,MAAA,EACA,WAAA,EACA,UAAA,EACA,UAAmB,IAAA,EACl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tContextMenuCommandBuilder,\n\tGuildMember,\n\tInteractionContextType,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tMessagePayload,\n\tSlashCommandBuilder,\n} from \"discord.js\";\nimport {\n\tCommandInteraction,\n\tCommandMetadata,\n\tContextMenuMetadata,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport {\n\tChatInputCommandInteraction,\n\tContextMenuCommandInteraction,\n\tSubcommand,\n} from \"src/index.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\tabstract data: SlashCommandBuilder | ContextMenuCommandBuilder;\n\tabstract metadata: CommandMetadata | ContextMenuMetadata;\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.data instanceof SlashCommandBuilder && 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.data instanceof ContextMenuCommandBuilder && 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) {\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\tconst isContextMenu = interaction.isContextMenuCommand();\n\t\tconst isChatInput = interaction.isChatInputCommand();\n\n\t\tconst requiresGuildCheck =\n\t\t\tisContextMenu || (isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false));\n\t\tif (!requiresGuildCheck) 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\tabstract data: SlashCommandBuilder;\n\tabstract metadata: CommandMetadata;\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 * @type {?(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ChatInputCommandInteraction\n\t * \t) => Promise<void>}\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 { run, reply, metadata } = this;\n\t\tconst { options } = interaction;\n\n\t\tif (run) {\n\t\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tmetadata.permission,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif (memberHasPermission) await run(client, interaction);\n\t\t}\n\n\t\tconst subcommands = metadata.subcommands;\n\t\tif (subcommands.size <= 0) return;\n\n\t\tconst subcommand = metadata.subcommands.find(\n\t\t\tsubcmd => subcmd.data.name === options.getSubcommand()\n\t\t);\n\t\tif (!subcommand) {\n\t\t\tawait reply(interaction, {\n\t\t\t\tcontent: \"Ran subcommand is outdated or does not have a handler!\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tsubcommand.metadata.permission\n\t\t);\n\t\tif (!memberHasPermission) 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\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._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\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: 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} 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\tabstract data: ContextMenuCommandBuilder;\n\tabstract metadata: ContextMenuMetadata;\n\t/**\n\t * Function to run when the command is used.\n\t *\n\t * @abstract\n\t * @type {(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ContextMenuCommandInteraction\n\t * \t) => Promise<void>}\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 { run, metadata } = this;\n\n\t\tconst memberHasPermission = await this.validateGuildPermission(\n\t\t\tclient,\n\t\t\tinteraction,\n\t\t\tmetadata.permission,\n\t\t\tfalse\n\t\t);\n\t\tif (memberHasPermission) await 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":["../../../src/core/commands/command.base.ts"],"names":["hasPerm"],"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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,oBAAA,GAAgE;AACtE,IAAA,OAAO,IAAA,YAAgB,kBAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,MAAA,GAAS;AACf,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,EAAO;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,KAAA,CACZ,WAAA,EACA,OAAA,EACC;AACD,IAAA,IAAI,WAAA,CAAY,OAAA,IAAW,WAAA,CAAY,QAAA,EAAU;AAChD,MAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,MAAA;AAAA,IACD;AAEA,IAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA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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.js","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 (!options.getSubcommand(false)) {\n\t\t\tif (this.run) {\n\t\t\t\tconst hasPerm = await this.validateGuildPermission(\n\t\t\t\t\tclient,\n\t\t\t\t\tinteraction,\n\t\t\t\t\tmetadata.permission,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tif (hasPerm) await this.run(client, interaction);\n\t\t\t}\n\t\t\treturn;\n\t\t}\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\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} 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"]}
|
|
@@ -71,6 +71,13 @@ class SubcommandBuilder extends discord_js.SlashCommandSubcommandBuilder {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
class Subcommand {
|
|
74
|
+
data;
|
|
75
|
+
metadata;
|
|
76
|
+
constructor(builder) {
|
|
77
|
+
const { data, metadata } = builder.build();
|
|
78
|
+
this.data = data;
|
|
79
|
+
this.metadata = metadata;
|
|
80
|
+
}
|
|
74
81
|
/**
|
|
75
82
|
* Reply to the interaction respecting command metadata and if the interaction has already been replied to.
|
|
76
83
|
*
|
|
@@ -80,7 +87,7 @@ class Subcommand {
|
|
|
80
87
|
* @returns {*}
|
|
81
88
|
*/
|
|
82
89
|
async reply(interaction, options) {
|
|
83
|
-
if (interaction.replied) {
|
|
90
|
+
if (interaction.replied || interaction.deferred) {
|
|
84
91
|
await interaction.editReply(options);
|
|
85
92
|
return;
|
|
86
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/commands/subcommand.base.ts"],"names":["SlashCommandSubcommandBuilder","PermissionLevel"],"mappings":";;;;;;;AAmBO,MAAM,0BAA0BA,wCAAA,CAA8B;AAAA,EAC5D,OAAA,GAAU,IAAA;AAAA,EACV,UAAA,GAAa,KAAA;AAAA,EACb,cAAcC,wBAAA,CAAgB,IAAA;AAAA,EAC9B,eAAA,GAAkB,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,OAAA,GAAgB;AACt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,WAAA,EACA,OAAA,EACC;AACD,IAAA,IAAI,WAAA,CAAY,OAAA,IAAW,WAAA,CAAY,QAAA,EAAU;AAChD,MAAA,MAAM,WAAA,CAAY,UAAU,OAAsC,CAAA;AAClE,MAAA;AAAA,IACD;AAEA,IAAA,MAAM,UAAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,IAAA,IAAI,KAAK,QAAA,CAAS,cAAA,EAAgB,UAAA,CAAW,KAAA,GAAQ,CAAC,WAAW,CAAA;AAEjE,IAAA,MAAM,WAAA,CAAY,MAAM,UAAU,CAAA;AAAA,EACnC;AACD","file":"subcommand.base.cjs","sourcesContent":["import {\n\tCacheType,\n\tChatInputCommandInteraction,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tMessagePayload,\n\tSlashCommandSubcommandBuilder,\n} from \"discord.js\";\nimport { PermissionLevel, SubcommandMetadata } from \"src/shared/typings/index.js\";\nimport { TriviousClient } from \"src/index.js\";\n\n/**\n * Base SubcommandBuilder.\n *\n * @export\n * @class SubcommandBuilder\n * @typedef {SubcommandBuilder}\n * @extends {SlashCommandSubcommandBuilder}\n */\nexport class SubcommandBuilder extends SlashCommandSubcommandBuilder {\n\tprivate _active = true;\n\tprivate _ownerOnly = false;\n\tprivate _permission = PermissionLevel.USER;\n\tprivate _ephemeralReply = false;\n\n\t/**\n\t * Set the subcommand 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 subcommand 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 subcommand.\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: SlashCommandSubcommandBuilder; metadata: SubcommandMetadata; }}\n\t */\n\tpublic build() {\n\t\treturn {\n\t\t\tdata: this as SlashCommandSubcommandBuilder,\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 SubcommandMetadata,\n\t\t};\n\t}\n}\n\n/**\n * Base Subcommand\n *\n * @export\n * @abstract\n * @class Subcommand\n * @typedef {Subcommand}\n */\nexport default abstract class Subcommand {\n\tpublic readonly data: SlashCommandSubcommandBuilder;\n\tpublic readonly metadata: SubcommandMetadata;\n\n\tprotected constructor(builder: SubcommandBuilder) {\n\t\tconst { data, metadata } = builder.build();\n\t\tthis.data = data;\n\t\tthis.metadata = metadata;\n\t}\n\n\t/**\n\t * Function to execute the subcommand.\n\t *\n\t * @abstract\n\t * @readonly\n\t * @type {(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ChatInputCommandInteraction<CacheType>\n\t * \t) => Promise<void>}\n\t */\n\tabstract readonly execute: (\n\t\tclient: TriviousClient,\n\t\tinteraction: ChatInputCommandInteraction<CacheType>\n\t) => Promise<void>;\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 * @async\n\t * @param {ChatInputCommandInteraction<CacheType>} interaction\n\t * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options\n\t * @returns {*}\n\t */\n\tasync reply(\n\t\tinteraction: ChatInputCommandInteraction<CacheType>,\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"]}
|
|
@@ -67,6 +67,13 @@ class SubcommandBuilder extends SlashCommandSubcommandBuilder {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
class Subcommand {
|
|
70
|
+
data;
|
|
71
|
+
metadata;
|
|
72
|
+
constructor(builder) {
|
|
73
|
+
const { data, metadata } = builder.build();
|
|
74
|
+
this.data = data;
|
|
75
|
+
this.metadata = metadata;
|
|
76
|
+
}
|
|
70
77
|
/**
|
|
71
78
|
* Reply to the interaction respecting command metadata and if the interaction has already been replied to.
|
|
72
79
|
*
|
|
@@ -76,7 +83,7 @@ class Subcommand {
|
|
|
76
83
|
* @returns {*}
|
|
77
84
|
*/
|
|
78
85
|
async reply(interaction, options) {
|
|
79
|
-
if (interaction.replied) {
|
|
86
|
+
if (interaction.replied || interaction.deferred) {
|
|
80
87
|
await interaction.editReply(options);
|
|
81
88
|
return;
|
|
82
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/commands/subcommand.base.ts"],"names":[],"mappings":";;;AAmBO,MAAM,0BAA0B,6BAAA,CAA8B;AAAA,EAC5D,OAAA,GAAU,IAAA;AAAA,EACV,UAAA,GAAa,KAAA;AAAA,EACb,cAAc,eAAA,CAAgB,IAAA;AAAA,EAC9B,eAAA,GAAkB,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,OAAA,GAAgB;AACtB,IAAA,IAAA,CAAK,OAAA,GAAU,KAAA;AACf,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,YAAA,GAAqB;AAC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AAA,GAAa,EAAE,GAAG,OAAA,EAAQ;AAChC,IAAA,IAAI,KAAK,QAAA,CAAS,cAAA,EAAgB,UAAA,CAAW,KAAA,GAAQ,CAAC,WAAW,CAAA;AAEjE,IAAA,MAAM,WAAA,CAAY,MAAM,UAAU,CAAA;AAAA,EACnC;AACD","file":"subcommand.base.js","sourcesContent":["import {\n\tCacheType,\n\tChatInputCommandInteraction,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tMessagePayload,\n\tSlashCommandSubcommandBuilder,\n} from \"discord.js\";\nimport { PermissionLevel, SubcommandMetadata } from \"src/shared/typings/index.js\";\nimport { TriviousClient } from \"src/index.js\";\n\n/**\n * Base SubcommandBuilder.\n *\n * @export\n * @class SubcommandBuilder\n * @typedef {SubcommandBuilder}\n * @extends {SlashCommandSubcommandBuilder}\n */\nexport class SubcommandBuilder extends SlashCommandSubcommandBuilder {\n\tprivate _active = true;\n\tprivate _ownerOnly = false;\n\tprivate _permission = PermissionLevel.USER;\n\tprivate _ephemeralReply = false;\n\n\t/**\n\t * Set the subcommand 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 subcommand 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 subcommand.\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: SlashCommandSubcommandBuilder; metadata: SubcommandMetadata; }}\n\t */\n\tpublic build() {\n\t\treturn {\n\t\t\tdata: this as SlashCommandSubcommandBuilder,\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 SubcommandMetadata,\n\t\t};\n\t}\n}\n\n/**\n * Base Subcommand\n *\n * @export\n * @abstract\n * @class Subcommand\n * @typedef {Subcommand}\n */\nexport default abstract class Subcommand {\n\tpublic readonly data: SlashCommandSubcommandBuilder;\n\tpublic readonly metadata: SubcommandMetadata;\n\n\tprotected constructor(builder: SubcommandBuilder) {\n\t\tconst { data, metadata } = builder.build();\n\t\tthis.data = data;\n\t\tthis.metadata = metadata;\n\t}\n\n\t/**\n\t * Function to execute the subcommand.\n\t *\n\t * @abstract\n\t * @readonly\n\t * @type {(\n\t * \t\tclient: TriviousClient,\n\t * \t\tinteraction: ChatInputCommandInteraction<CacheType>\n\t * \t) => Promise<void>}\n\t */\n\tabstract readonly execute: (\n\t\tclient: TriviousClient,\n\t\tinteraction: ChatInputCommandInteraction<CacheType>\n\t) => Promise<void>;\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 * @async\n\t * @param {ChatInputCommandInteraction<CacheType>} interaction\n\t * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options\n\t * @returns {*}\n\t */\n\tasync reply(\n\t\tinteraction: ChatInputCommandInteraction<CacheType>,\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-DQ3Y6DvJ.cjs';
|
|
2
2
|
import '../../shared/typings/registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-Bf8pz7za.js';
|
|
2
2
|
import '../../shared/typings/registry.js';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRegistry } from './shared/typings/registry.js';
|
|
2
2
|
import * as discord_js from 'discord.js';
|
|
3
|
-
import { GuildMember, AnySelectMenuInteraction, CacheType, ButtonInteraction as ButtonInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, SlashCommandBuilder, ContextMenuCommandBuilder, MessagePayload, InteractionEditReplyOptions, InteractionReplyOptions,
|
|
3
|
+
import { GuildMember, AnySelectMenuInteraction, CacheType, ButtonInteraction as ButtonInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, SlashCommandBuilder, ContextMenuCommandBuilder, Collection, MessagePayload, InteractionEditReplyOptions, InteractionReplyOptions, SlashCommandSubcommandBuilder, ChatInputCommandInteraction as ChatInputCommandInteraction$1, ClientOptions, ClientEvents, ComponentType as ComponentType$1, Client, StringSelectMenuInteraction as StringSelectMenuInteraction$1, ContextMenuCommandInteraction as ContextMenuCommandInteraction$1 } from 'discord.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* User permission level enums
|
|
@@ -97,8 +97,9 @@ declare const deconstructCustomId: (customId: string) => {
|
|
|
97
97
|
* @typedef {Command}
|
|
98
98
|
*/
|
|
99
99
|
declare abstract class Command {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
readonly data: SlashCommandBuilder | ContextMenuCommandBuilder;
|
|
101
|
+
readonly metadata: AnyCommandMetadata;
|
|
102
|
+
protected constructor(builder: AnyCommandBuilder);
|
|
102
103
|
/**
|
|
103
104
|
* Returns whether the command is a SlashCommand.
|
|
104
105
|
*
|
|
@@ -153,16 +154,13 @@ declare abstract class Command {
|
|
|
153
154
|
* @extends {Command}
|
|
154
155
|
*/
|
|
155
156
|
declare abstract class SlashCommand extends Command {
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
readonly data: SlashCommandBuilder;
|
|
158
|
+
readonly metadata: CommandMetadata;
|
|
159
|
+
protected constructor(builder: CommandBuilder);
|
|
158
160
|
/**
|
|
159
161
|
* Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
|
|
160
162
|
*
|
|
161
163
|
* @abstract
|
|
162
|
-
* @type {?(
|
|
163
|
-
* client: TriviousClient,
|
|
164
|
-
* interaction: ChatInputCommandInteraction
|
|
165
|
-
* ) => Promise<void>}
|
|
166
164
|
*/
|
|
167
165
|
run?: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
|
|
168
166
|
/**
|
|
@@ -255,16 +253,13 @@ declare class CommandBuilder extends SlashCommandBuilder {
|
|
|
255
253
|
* @extends {Command}
|
|
256
254
|
*/
|
|
257
255
|
declare abstract class ContextMenuCommand extends Command {
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
readonly data: ContextMenuCommandBuilder;
|
|
257
|
+
readonly metadata: ContextMenuMetadata;
|
|
258
|
+
protected constructor(builder: ContextMenuBuilder);
|
|
260
259
|
/**
|
|
261
260
|
* Function to run when the command is used.
|
|
262
261
|
*
|
|
263
262
|
* @abstract
|
|
264
|
-
* @type {(
|
|
265
|
-
* client: TriviousClient,
|
|
266
|
-
* interaction: ContextMenuCommandInteraction
|
|
267
|
-
* ) => Promise<void>}
|
|
268
263
|
*/
|
|
269
264
|
abstract run: (client: TriviousClient, interaction: ContextMenuCommandInteraction) => Promise<void>;
|
|
270
265
|
/**
|
|
@@ -404,8 +399,9 @@ declare class SubcommandBuilder extends SlashCommandSubcommandBuilder {
|
|
|
404
399
|
* @typedef {Subcommand}
|
|
405
400
|
*/
|
|
406
401
|
declare abstract class Subcommand {
|
|
407
|
-
|
|
408
|
-
|
|
402
|
+
readonly data: SlashCommandSubcommandBuilder;
|
|
403
|
+
readonly metadata: SubcommandMetadata;
|
|
404
|
+
protected constructor(builder: SubcommandBuilder);
|
|
409
405
|
/**
|
|
410
406
|
* Function to execute the subcommand.
|
|
411
407
|
*
|
|
@@ -553,6 +549,8 @@ interface ContextMenuMetadata {
|
|
|
553
549
|
* @typedef {AnyCommand}
|
|
554
550
|
*/
|
|
555
551
|
type AnyCommand = SlashCommand | ContextMenuCommand;
|
|
552
|
+
type AnyCommandBuilder = CommandBuilder | ContextMenuBuilder;
|
|
553
|
+
type AnyCommandMetadata = CommandMetadata | ContextMenuMetadata;
|
|
556
554
|
|
|
557
555
|
/**
|
|
558
556
|
* Client options for the TriviousClient
|
|
@@ -950,4 +948,4 @@ type StringSelectMenuInteraction = StringSelectMenuInteraction$1<CacheType>;
|
|
|
950
948
|
type ModalSubmitInteraction = ModalSubmitInteraction$1<CacheType>;
|
|
951
949
|
type ContextMenuCommandInteraction = ContextMenuCommandInteraction$1<CacheType>;
|
|
952
950
|
|
|
953
|
-
export { type AnyCommand as A, type ButtonInteraction as B, CommandRegistry as C, EventRegistry as E, ModuleRegistry as M, PermissionLevel as P, SlashCommand as S, TriviousClient as T, ComponentRegistry as a, type TriviousClientOptions as b, type ComponentCustomIdTag as c, type ComponentInteraction as d, ComponentType as e, type ComponentMetadata as f, getPermissionLevel as g, deconstructCustomId as h, Command as i, CommandBuilder as j, ContextMenuCommand as k, ContextMenuBuilder as l, Subcommand as m, SubcommandBuilder as n, type CommandInteraction as o, type CommandMetadata as p, type SubcommandMetadata as q, type ContextMenuMetadata as r, type
|
|
951
|
+
export { type AnyCommand as A, type ButtonInteraction as B, CommandRegistry as C, type ModalSubmitInteraction as D, EventRegistry as E, type ContextMenuCommandInteraction as F, ModuleRegistry as M, PermissionLevel as P, SlashCommand as S, TriviousClient as T, ComponentRegistry as a, type TriviousClientOptions as b, type ComponentCustomIdTag as c, type ComponentInteraction as d, ComponentType as e, type ComponentMetadata as f, getPermissionLevel as g, deconstructCustomId as h, Command as i, CommandBuilder as j, ContextMenuCommand as k, ContextMenuBuilder as l, Subcommand as m, SubcommandBuilder as n, type CommandInteraction as o, type CommandMetadata as p, type SubcommandMetadata as q, type ContextMenuMetadata as r, type AnyCommandBuilder as s, type AnyCommandMetadata as t, type Event as u, type Module as v, Component as w, ComponentBuilder as x, type ChatInputCommandInteraction as y, type StringSelectMenuInteraction as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRegistry } from './shared/typings/registry.cjs';
|
|
2
2
|
import * as discord_js from 'discord.js';
|
|
3
|
-
import { GuildMember, AnySelectMenuInteraction, CacheType, ButtonInteraction as ButtonInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, SlashCommandBuilder, ContextMenuCommandBuilder, MessagePayload, InteractionEditReplyOptions, InteractionReplyOptions,
|
|
3
|
+
import { GuildMember, AnySelectMenuInteraction, CacheType, ButtonInteraction as ButtonInteraction$1, ModalSubmitInteraction as ModalSubmitInteraction$1, SlashCommandBuilder, ContextMenuCommandBuilder, Collection, MessagePayload, InteractionEditReplyOptions, InteractionReplyOptions, SlashCommandSubcommandBuilder, ChatInputCommandInteraction as ChatInputCommandInteraction$1, ClientOptions, ClientEvents, ComponentType as ComponentType$1, Client, StringSelectMenuInteraction as StringSelectMenuInteraction$1, ContextMenuCommandInteraction as ContextMenuCommandInteraction$1 } from 'discord.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* User permission level enums
|
|
@@ -97,8 +97,9 @@ declare const deconstructCustomId: (customId: string) => {
|
|
|
97
97
|
* @typedef {Command}
|
|
98
98
|
*/
|
|
99
99
|
declare abstract class Command {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
readonly data: SlashCommandBuilder | ContextMenuCommandBuilder;
|
|
101
|
+
readonly metadata: AnyCommandMetadata;
|
|
102
|
+
protected constructor(builder: AnyCommandBuilder);
|
|
102
103
|
/**
|
|
103
104
|
* Returns whether the command is a SlashCommand.
|
|
104
105
|
*
|
|
@@ -153,16 +154,13 @@ declare abstract class Command {
|
|
|
153
154
|
* @extends {Command}
|
|
154
155
|
*/
|
|
155
156
|
declare abstract class SlashCommand extends Command {
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
readonly data: SlashCommandBuilder;
|
|
158
|
+
readonly metadata: CommandMetadata;
|
|
159
|
+
protected constructor(builder: CommandBuilder);
|
|
158
160
|
/**
|
|
159
161
|
* Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
|
|
160
162
|
*
|
|
161
163
|
* @abstract
|
|
162
|
-
* @type {?(
|
|
163
|
-
* client: TriviousClient,
|
|
164
|
-
* interaction: ChatInputCommandInteraction
|
|
165
|
-
* ) => Promise<void>}
|
|
166
164
|
*/
|
|
167
165
|
run?: (client: TriviousClient, interaction: ChatInputCommandInteraction) => Promise<void>;
|
|
168
166
|
/**
|
|
@@ -255,16 +253,13 @@ declare class CommandBuilder extends SlashCommandBuilder {
|
|
|
255
253
|
* @extends {Command}
|
|
256
254
|
*/
|
|
257
255
|
declare abstract class ContextMenuCommand extends Command {
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
readonly data: ContextMenuCommandBuilder;
|
|
257
|
+
readonly metadata: ContextMenuMetadata;
|
|
258
|
+
protected constructor(builder: ContextMenuBuilder);
|
|
260
259
|
/**
|
|
261
260
|
* Function to run when the command is used.
|
|
262
261
|
*
|
|
263
262
|
* @abstract
|
|
264
|
-
* @type {(
|
|
265
|
-
* client: TriviousClient,
|
|
266
|
-
* interaction: ContextMenuCommandInteraction
|
|
267
|
-
* ) => Promise<void>}
|
|
268
263
|
*/
|
|
269
264
|
abstract run: (client: TriviousClient, interaction: ContextMenuCommandInteraction) => Promise<void>;
|
|
270
265
|
/**
|
|
@@ -404,8 +399,9 @@ declare class SubcommandBuilder extends SlashCommandSubcommandBuilder {
|
|
|
404
399
|
* @typedef {Subcommand}
|
|
405
400
|
*/
|
|
406
401
|
declare abstract class Subcommand {
|
|
407
|
-
|
|
408
|
-
|
|
402
|
+
readonly data: SlashCommandSubcommandBuilder;
|
|
403
|
+
readonly metadata: SubcommandMetadata;
|
|
404
|
+
protected constructor(builder: SubcommandBuilder);
|
|
409
405
|
/**
|
|
410
406
|
* Function to execute the subcommand.
|
|
411
407
|
*
|
|
@@ -553,6 +549,8 @@ interface ContextMenuMetadata {
|
|
|
553
549
|
* @typedef {AnyCommand}
|
|
554
550
|
*/
|
|
555
551
|
type AnyCommand = SlashCommand | ContextMenuCommand;
|
|
552
|
+
type AnyCommandBuilder = CommandBuilder | ContextMenuBuilder;
|
|
553
|
+
type AnyCommandMetadata = CommandMetadata | ContextMenuMetadata;
|
|
556
554
|
|
|
557
555
|
/**
|
|
558
556
|
* Client options for the TriviousClient
|
|
@@ -950,4 +948,4 @@ type StringSelectMenuInteraction = StringSelectMenuInteraction$1<CacheType>;
|
|
|
950
948
|
type ModalSubmitInteraction = ModalSubmitInteraction$1<CacheType>;
|
|
951
949
|
type ContextMenuCommandInteraction = ContextMenuCommandInteraction$1<CacheType>;
|
|
952
950
|
|
|
953
|
-
export { type AnyCommand as A, type ButtonInteraction as B, CommandRegistry as C, EventRegistry as E, ModuleRegistry as M, PermissionLevel as P, SlashCommand as S, TriviousClient as T, ComponentRegistry as a, type TriviousClientOptions as b, type ComponentCustomIdTag as c, type ComponentInteraction as d, ComponentType as e, type ComponentMetadata as f, getPermissionLevel as g, deconstructCustomId as h, Command as i, CommandBuilder as j, ContextMenuCommand as k, ContextMenuBuilder as l, Subcommand as m, SubcommandBuilder as n, type CommandInteraction as o, type CommandMetadata as p, type SubcommandMetadata as q, type ContextMenuMetadata as r, type
|
|
951
|
+
export { type AnyCommand as A, type ButtonInteraction as B, CommandRegistry as C, type ModalSubmitInteraction as D, EventRegistry as E, type ContextMenuCommandInteraction as F, ModuleRegistry as M, PermissionLevel as P, SlashCommand as S, TriviousClient as T, ComponentRegistry as a, type TriviousClientOptions as b, type ComponentCustomIdTag as c, type ComponentInteraction as d, ComponentType as e, type ComponentMetadata as f, getPermissionLevel as g, deconstructCustomId as h, Command as i, CommandBuilder as j, ContextMenuCommand as k, ContextMenuBuilder as l, Subcommand as m, SubcommandBuilder as n, type CommandInteraction as o, type CommandMetadata as p, type SubcommandMetadata as q, type ContextMenuMetadata as r, type AnyCommandBuilder as s, type AnyCommandMetadata as t, type Event as u, type Module as v, Component as w, ComponentBuilder as x, type ChatInputCommandInteraction as y, type StringSelectMenuInteraction as z };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction,
|
|
2
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, B as ButtonInteraction, y as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, w as Component, x as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, F as ContextMenuCommandInteraction, r as ContextMenuMetadata, u as Event, D as ModalSubmitInteraction, v as Module, P as PermissionLevel, S as SlashCommand, z as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-DQ3Y6DvJ.cjs';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction,
|
|
2
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, B as ButtonInteraction, y as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, w as Component, x as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, F as ContextMenuCommandInteraction, r as ContextMenuMetadata, u as Event, D as ModalSubmitInteraction, v as Module, P as PermissionLevel, S as SlashCommand, z as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-Bf8pz7za.js';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-DQ3Y6DvJ.cjs';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-Bf8pz7za.js';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-DQ3Y6DvJ.cjs';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-Bf8pz7za.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata,
|
|
1
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, u as Event, v as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-DQ3Y6DvJ.cjs';
|
|
2
2
|
export { BaseRegistry } from './registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata,
|
|
1
|
+
export { A as AnyCommand, s as AnyCommandBuilder, t as AnyCommandMetadata, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, u as Event, v as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-Bf8pz7za.js';
|
|
2
2
|
export { BaseRegistry } from './registry.js';
|
|
3
3
|
import 'discord.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-DQ3Y6DvJ.cjs';
|
|
2
2
|
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-Bf8pz7za.js';
|
|
2
2
|
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.js';
|
|
4
4
|
|