trivious 2.3.6 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/client/client.types.d.ts +14 -1
- package/dist/features/client/deploy.client.d.ts +1 -1
- package/dist/features/client/deploy.client.js +1 -1
- package/dist/features/client/deploy.client.js.map +1 -1
- package/dist/features/client/logger.js +4 -5
- package/dist/features/client/logger.js.map +1 -1
- package/dist/features/client/trivious.client.d.ts +1 -1
- package/dist/features/client/trivious.client.js +11 -8
- package/dist/features/client/trivious.client.js.map +1 -1
- package/dist/features/commands/builders.commands.d.ts +3 -2
- package/dist/features/commands/builders.commands.js +9 -0
- package/dist/features/commands/builders.commands.js.map +1 -1
- package/dist/features/commands/commands.types.d.ts +1 -1
- package/dist/features/commands/handlers/message.commands.d.ts +15 -0
- package/dist/features/commands/handlers/message.commands.js +109 -0
- package/dist/features/commands/handlers/message.commands.js.map +1 -0
- package/dist/features/commands/handlers/slash.commands.d.ts +9 -0
- package/dist/features/commands/handlers/slash.commands.js +74 -0
- package/dist/features/commands/handlers/slash.commands.js.map +1 -0
- package/dist/features/commands/methods.commands.d.ts +3 -4
- package/dist/features/commands/methods.commands.js +0 -70
- package/dist/features/commands/methods.commands.js.map +1 -1
- package/dist/features/commands/presets/help.d.ts +13 -0
- package/dist/features/commands/presets/help.js +40 -0
- package/dist/features/commands/presets/help.js.map +1 -0
- package/dist/features/commands/registry.commands.d.ts +1 -5
- package/dist/features/commands/registry.commands.js +44 -4
- package/dist/features/commands/registry.commands.js.map +1 -1
- package/dist/features/commands/utility.d.ts +12 -0
- package/dist/features/commands/utility.js +31 -0
- package/dist/features/commands/utility.js.map +1 -0
- package/dist/features/components/builders.components.d.ts +1 -1
- package/dist/features/components/builders.components.js +1 -1
- package/dist/features/components/builders.components.js.map +1 -1
- package/dist/features/components/components.types.d.ts +1 -1
- package/dist/features/components/components.types.js.map +1 -1
- package/dist/features/components/registry.components.d.ts +1 -5
- package/dist/features/components/registry.components.js +3 -3
- package/dist/features/components/registry.components.js.map +1 -1
- package/dist/features/customId/customid.types.d.ts +1 -1
- package/dist/features/customId/methods.customid.d.ts +1 -1
- package/dist/features/customId/methods.customid.js +1 -1
- package/dist/features/customId/methods.customid.js.map +1 -1
- package/dist/features/events/events.types.d.ts +1 -1
- package/dist/features/events/presets/clientReady.d.ts +1 -1
- package/dist/features/events/presets/clientReady.js.map +1 -1
- package/dist/features/events/presets/interactionCreate.d.ts +2 -1
- package/dist/features/events/presets/interactionCreate.js +9 -4
- package/dist/features/events/presets/interactionCreate.js.map +1 -1
- package/dist/features/events/presets/messageCreate.d.ts +13 -0
- package/dist/features/events/presets/messageCreate.js +128 -0
- package/dist/features/events/presets/messageCreate.js.map +1 -0
- package/dist/features/events/registry.events.d.ts +1 -6
- package/dist/features/events/registry.events.js +16 -3
- package/dist/features/events/registry.events.js.map +1 -1
- package/dist/features/modules/modules.types.d.ts +1 -1
- package/dist/features/modules/registry.modules.d.ts +1 -6
- package/dist/features/modules/registry.modules.js +2 -2
- package/dist/features/modules/registry.modules.js.map +1 -1
- package/dist/features/permissions/methods.permissions.d.ts +3 -3
- package/dist/features/permissions/methods.permissions.js +1 -0
- package/dist/features/permissions/methods.permissions.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/{modules.types-D-tuJArP.d.ts → modules.types-BgGFvIsW.d.ts} +87 -7
- package/dist/shared/registries.d.ts +1 -5
- package/dist/shared/registries.js +4 -4
- package/dist/shared/registries.js.map +1 -1
- package/dist/shared/typings.d.ts +2 -2
- package/dist/shared/typings.js +8 -8
- package/dist/shared/typings.js.map +1 -1
- package/dist/utility/errors.d.ts +1 -1
- package/dist/utility/errors.js.map +1 -1
- package/dist/utility/functions.d.ts +1 -1
- package/dist/utility/functions.js.map +1 -1
- package/package.json +16 -11
|
@@ -67,6 +67,18 @@ interface CommandHashConfiguration {
|
|
|
67
67
|
enabled: boolean;
|
|
68
68
|
persistentDataPath: string;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Message command configuration
|
|
72
|
+
*
|
|
73
|
+
* @param prefix Usually a single character (e.g. `?`, `!`, `.`) to identify message commands
|
|
74
|
+
* @param delimiter Specific character(s) and/or symbol(s) to mark boundary of strings, mainly for use by `sentence` argument types
|
|
75
|
+
*/
|
|
76
|
+
interface MessageCommandConfiguration {
|
|
77
|
+
/**
|
|
78
|
+
* Recommended value(s): `?` `!` `.`
|
|
79
|
+
*/
|
|
80
|
+
prefix: string;
|
|
81
|
+
}
|
|
70
82
|
/**
|
|
71
83
|
* Trivious client options
|
|
72
84
|
*
|
|
@@ -81,6 +93,7 @@ interface TriviousClientOptions extends ClientOptions {
|
|
|
81
93
|
ownerUserIds?: string[];
|
|
82
94
|
commandHashConfig?: CommandHashConfiguration;
|
|
83
95
|
debug?: boolean;
|
|
96
|
+
messageCommands?: MessageCommandConfiguration;
|
|
84
97
|
}
|
|
85
98
|
|
|
86
|
-
export type { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure };
|
|
99
|
+
export type { CommandHashConfiguration, FeatureBasedStructure, MessageCommandConfiguration, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/client/deploy.client.ts"],"sourcesContent":["import { TriviousError } from \"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/client/deploy.client.ts"],"sourcesContent":["import { TriviousError } from \"#utility/errors.js\";\nimport { createHash } from \"crypto\";\nimport { REST, Routes } from \"discord.js\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport TriviousClient from \"./trivious.client.js\";\n\nexport default async function commandDeploy(client: TriviousClient) {\n\tconst { commandHashConfig } = client.trivious;\n\n\tconst clientId = process.env[client.trivious.credentials.clientIdReference];\n\tconst token = process.env[client.trivious.credentials.tokenReference];\n\tif (!clientId || !token)\n\t\tthrow new TriviousError(\"Invalid clientId or token environment variable\");\n\n\tconst commands = client.stores.commands;\n\tconst body = [\n\t\t...commands.chatInput.map((command) => command.data.toJSON()),\n\t\t...commands.context.map((command) => command.data.toJSON()),\n\t];\n\n\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\tconst hashFile = join(commandHashConfig.persistentDataPath || \"data\", \"commands.hash\");\n\t\tconst newHash = createHash(\"sha256\")\n\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t.digest(\"hex\");\n\n\t\tlet oldHash = \"\";\n\t\tif (existsSync(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\n\t\tif (body.length === 0 && !oldHash) {\n\t\t\tconsole.debug(`[Trivious] No commands found, skipping deployment.`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (newHash === oldHash) {\n\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment.`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst hashDirectory = dirname(hashFile);\n\t\tif (!existsSync(hashDirectory)) {\n\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t}\n\n\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t}\n\n\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\tconsole.debug(`[Trivious] Deployed ${body.length} commands`);\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,cAAc;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,SAAS,YAAY;AAG9B,eAAO,cAAqC,QAAwB;AACnE,QAAM,EAAE,kBAAkB,IAAI,OAAO;AAErC,QAAM,WAAW,QAAQ,IAAI,OAAO,SAAS,YAAY,iBAAiB;AAC1E,QAAM,QAAQ,QAAQ,IAAI,OAAO,SAAS,YAAY,cAAc;AACpE,MAAI,CAAC,YAAY,CAAC;AACjB,UAAM,IAAI,cAAc,gDAAgD;AAEzE,QAAM,WAAW,OAAO,OAAO;AAC/B,QAAM,OAAO;AAAA,IACZ,GAAG,SAAS,UAAU,IAAI,CAAC,YAAY,QAAQ,KAAK,OAAO,CAAC;AAAA,IAC5D,GAAG,SAAS,QAAQ,IAAI,CAAC,YAAY,QAAQ,KAAK,OAAO,CAAC;AAAA,EAC3D;AAEA,MAAI,qBAAqB,kBAAkB,SAAS;AACnD,UAAM,WAAW,KAAK,kBAAkB,sBAAsB,QAAQ,eAAe;AACrF,UAAM,UAAU,WAAW,QAAQ,EACjC,OAAO,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,EACnF,OAAO,KAAK;AAEd,QAAI,UAAU;AACd,QAAI,WAAW,QAAQ,EAAG,WAAU,aAAa,UAAU,OAAO;AAElE,QAAI,KAAK,WAAW,KAAK,CAAC,SAAS;AAClC,cAAQ,MAAM,oDAAoD;AAClE;AAAA,IACD;AAEA,QAAI,YAAY,SAAS;AACxB,cAAQ,MAAM,+DAA+D;AAC7E;AAAA,IACD;AAEA,UAAM,gBAAgB,QAAQ,QAAQ;AACtC,QAAI,CAAC,WAAW,aAAa,GAAG;AAC/B,gBAAU,eAAe,EAAE,WAAW,KAAK,CAAC;AAAA,IAC7C;AAEA,kBAAc,UAAU,SAAS,EAAE,UAAU,QAAQ,CAAC;AACtD,YAAQ,MAAM,wCAAwC,QAAQ,EAAE;AAAA,EACjE;AAEA,QAAM,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC,EAAE,SAAS,KAAK;AACvD,QAAM,KAAK,IAAI,OAAO,oBAAoB,QAAQ,GAAG,EAAE,KAAK,CAAC;AAC7D,UAAQ,MAAM,uBAAuB,KAAK,MAAM,WAAW;AAC5D;","names":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
1
|
class Logger {
|
|
3
2
|
constructor(prefix = "Trivious", debugActive = false) {
|
|
4
3
|
this.prefix = prefix;
|
|
@@ -6,16 +5,16 @@ class Logger {
|
|
|
6
5
|
}
|
|
7
6
|
debug(...args) {
|
|
8
7
|
if (!this.debugActive) return;
|
|
9
|
-
console.log(
|
|
8
|
+
console.log(`[${this.prefix}] [DEBUG]`, ...args);
|
|
10
9
|
}
|
|
11
10
|
info(...args) {
|
|
12
|
-
console.log(
|
|
11
|
+
console.log(`[${this.prefix}]`, ...args);
|
|
13
12
|
}
|
|
14
13
|
warn(...args) {
|
|
15
|
-
console.log(
|
|
14
|
+
console.log(`[${this.prefix}] [WARN]`, ...args);
|
|
16
15
|
}
|
|
17
16
|
error(...args) {
|
|
18
|
-
console.log(
|
|
17
|
+
console.log(`[${this.prefix}] [ERROR]`, ...args);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/client/logger.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/features/client/logger.ts"],"sourcesContent":["export class Logger {\n\tconstructor(\n\t\tprivate prefix = \"Trivious\",\n\t\tprivate debugActive = false\n\t) {}\n\n\tdebug(...args: any[]) {\n\t\tif (!this.debugActive) return;\n\t\tconsole.log(`[${this.prefix}] [DEBUG]`, ...args);\n\t}\n\n\tinfo(...args: any[]) {\n\t\tconsole.log(`[${this.prefix}]`, ...args);\n\t}\n\n\twarn(...args: any[]) {\n\t\tconsole.log(`[${this.prefix}] [WARN]`, ...args);\n\t}\n\n\terror(...args: any[]) {\n\t\tconsole.log(`[${this.prefix}] [ERROR]`, ...args);\n\t}\n}\n"],"mappings":"AAAO,MAAM,OAAO;AAAA,EACnB,YACS,SAAS,YACT,cAAc,OACrB;AAFO;AACA;AAAA,EACN;AAAA,EAEH,SAAS,MAAa;AACrB,QAAI,CAAC,KAAK,YAAa;AACvB,YAAQ,IAAI,IAAI,KAAK,MAAM,aAAa,GAAG,IAAI;AAAA,EAChD;AAAA,EAEA,QAAQ,MAAa;AACpB,YAAQ,IAAI,IAAI,KAAK,MAAM,KAAK,GAAG,IAAI;AAAA,EACxC;AAAA,EAEA,QAAQ,MAAa;AACpB,YAAQ,IAAI,IAAI,KAAK,MAAM,YAAY,GAAG,IAAI;AAAA,EAC/C;AAAA,EAEA,SAAS,MAAa;AACrB,YAAQ,IAAI,IAAI,KAAK,MAAM,aAAa,GAAG,IAAI;AAAA,EAChD;AACD;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import registries from "
|
|
1
|
+
import registries from "#shared/registries.js";
|
|
2
2
|
import { Client, Collection } from "discord.js";
|
|
3
3
|
import structure from "../structure/index.structure.js";
|
|
4
|
-
import { TriviousError } from "
|
|
4
|
+
import { TriviousError } from "#utility/errors.js";
|
|
5
5
|
import commandDeploy from "./deploy.client.js";
|
|
6
6
|
import { Logger } from "./logger.js";
|
|
7
7
|
class TriviousClient extends Client {
|
|
8
8
|
trivious;
|
|
9
|
+
registries = registries;
|
|
9
10
|
stores;
|
|
10
11
|
logger;
|
|
11
12
|
constructor(options) {
|
|
@@ -15,11 +16,13 @@ class TriviousClient extends Client {
|
|
|
15
16
|
this.stores = {
|
|
16
17
|
commands: {
|
|
17
18
|
chatInput: new Collection(),
|
|
18
|
-
context: new Collection()
|
|
19
|
+
context: new Collection(),
|
|
20
|
+
message: new Collection()
|
|
19
21
|
},
|
|
20
22
|
components: new Collection(),
|
|
21
23
|
events: new Collection(),
|
|
22
|
-
modules: new Collection()
|
|
24
|
+
modules: new Collection(),
|
|
25
|
+
messageCommandAliases: new Collection()
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -27,7 +30,7 @@ class TriviousClient extends Client {
|
|
|
27
30
|
*
|
|
28
31
|
* @throws {TriviousError} If invalid bot token
|
|
29
32
|
*/
|
|
30
|
-
async start() {
|
|
33
|
+
async start(deploy) {
|
|
31
34
|
const token = process.env[this.trivious.credentials.tokenReference];
|
|
32
35
|
if (!token) {
|
|
33
36
|
throw new TriviousError(
|
|
@@ -36,7 +39,7 @@ class TriviousClient extends Client {
|
|
|
36
39
|
);
|
|
37
40
|
}
|
|
38
41
|
await this.register();
|
|
39
|
-
await this.deploy();
|
|
42
|
+
if (deploy || deploy === void 0) await this.deploy();
|
|
40
43
|
try {
|
|
41
44
|
await registries.events.bind(this);
|
|
42
45
|
await registries.modules.bind(this);
|
|
@@ -48,10 +51,10 @@ class TriviousClient extends Client {
|
|
|
48
51
|
}
|
|
49
52
|
async register() {
|
|
50
53
|
const dir = structure.resolveRelativePath(this.trivious.corePath);
|
|
51
|
-
await registries.events.register(this, dir);
|
|
52
|
-
await registries.modules.register(this, dir);
|
|
53
54
|
await registries.commands.register(this, dir);
|
|
54
55
|
await registries.components.register(this, dir);
|
|
56
|
+
await registries.events.register(this, dir);
|
|
57
|
+
await registries.modules.register(this, dir);
|
|
55
58
|
}
|
|
56
59
|
async deploy() {
|
|
57
60
|
await commandDeploy(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/client/trivious.client.ts"],"sourcesContent":["import registries from \"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/client/trivious.client.ts"],"sourcesContent":["import registries from \"#shared/registries.js\";\nimport { Client, Collection } from \"discord.js\";\nimport structure from \"../structure/index.structure.js\";\n\nimport {\n\tComponent,\n\tContextCommandData,\n\tEvent,\n\tMessageCommandData,\n\tModule,\n\tSlashCommandData,\n\tTriviousClientOptions,\n} from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport commandDeploy from \"./deploy.client.js\";\nimport { Logger } from \"./logger.js\";\n\nexport default class TriviousClient extends Client {\n\ttrivious: TriviousClientOptions;\n\treadonly registries = registries;\n\treadonly stores: {\n\t\tcommands: {\n\t\t\tchatInput: Collection<string, SlashCommandData>;\n\t\t\tcontext: Collection<string, ContextCommandData>;\n\t\t\tmessage: Collection<string, MessageCommandData<true>>;\n\t\t};\n\t\tcomponents: Collection<string, Component>;\n\t\tevents: Collection<string, Event>;\n\t\tmodules: Collection<string, Module>;\n\t\tmessageCommandAliases: Collection<string, string>;\n\t};\n\tlogger: Logger;\n\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis.trivious = options;\n\t\tthis.logger = new Logger(\"Trivious\", !!options.debug);\n\n\t\tthis.stores = {\n\t\t\tcommands: {\n\t\t\t\tchatInput: new Collection(),\n\t\t\t\tcontext: new Collection(),\n\t\t\t\tmessage: new Collection(),\n\t\t\t},\n\t\t\tcomponents: new Collection(),\n\t\t\tevents: new Collection(),\n\t\t\tmodules: new Collection(),\n\t\t\tmessageCommandAliases: new Collection(),\n\t\t};\n\t}\n\n\t/**\n\t * Register, deploy and log into the bot.\n\t *\n\t * @throws {TriviousError} If invalid bot token\n\t */\n\tasync start(deploy?: boolean) {\n\t\tconst token = process.env[this.trivious.credentials.tokenReference];\n\t\tif (!token) {\n\t\t\tthrow new TriviousError(\n\t\t\t\t`Bot token environment variable '${this.trivious.credentials.tokenReference}' does not exist!`,\n\t\t\t\t\"Null environment variable\"\n\t\t\t);\n\t\t}\n\n\t\tawait this.register();\n\t\tif (deploy || deploy === undefined) await this.deploy();\n\n\t\ttry {\n\t\t\tawait registries.events.bind(this);\n\t\t\tawait registries.modules.bind(this);\n\t\t} catch (err: any) {\n\t\t\tconst error = new TriviousError(err.message, \"Error during events and modules binds\");\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\tawait this.login(token);\n\t}\n\n\tasync register() {\n\t\tconst dir = structure.resolveRelativePath(this.trivious.corePath);\n\t\tawait registries.commands.register(this, dir);\n\t\tawait registries.components.register(this, dir);\n\t\tawait registries.events.register(this, dir);\n\t\tawait registries.modules.register(this, dir);\n\t}\n\n\tasync deploy() {\n\t\tawait commandDeploy(this);\n\t}\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,SAAS,QAAQ,kBAAkB;AACnC,OAAO,eAAe;AAWtB,SAAS,qBAAqB;AAC9B,OAAO,mBAAmB;AAC1B,SAAS,cAAc;AAEvB,MAAO,uBAAqC,OAAO;AAAA,EAClD;AAAA,EACS,aAAa;AAAA,EACb;AAAA,EAWT;AAAA,EAEA,YAAY,SAAgC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW;AAChB,SAAK,SAAS,IAAI,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAK;AAEpD,SAAK,SAAS;AAAA,MACb,UAAU;AAAA,QACT,WAAW,IAAI,WAAW;AAAA,QAC1B,SAAS,IAAI,WAAW;AAAA,QACxB,SAAS,IAAI,WAAW;AAAA,MACzB;AAAA,MACA,YAAY,IAAI,WAAW;AAAA,MAC3B,QAAQ,IAAI,WAAW;AAAA,MACvB,SAAS,IAAI,WAAW;AAAA,MACxB,uBAAuB,IAAI,WAAW;AAAA,IACvC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAM,QAAkB;AAC7B,UAAM,QAAQ,QAAQ,IAAI,KAAK,SAAS,YAAY,cAAc;AAClE,QAAI,CAAC,OAAO;AACX,YAAM,IAAI;AAAA,QACT,mCAAmC,KAAK,SAAS,YAAY,cAAc;AAAA,QAC3E;AAAA,MACD;AAAA,IACD;AAEA,UAAM,KAAK,SAAS;AACpB,QAAI,UAAU,WAAW,OAAW,OAAM,KAAK,OAAO;AAEtD,QAAI;AACH,YAAM,WAAW,OAAO,KAAK,IAAI;AACjC,YAAM,WAAW,QAAQ,KAAK,IAAI;AAAA,IACnC,SAAS,KAAU;AAClB,YAAM,QAAQ,IAAI,cAAc,IAAI,SAAS,uCAAuC;AACpF,cAAQ,MAAM,KAAK;AAAA,IACpB;AAEA,UAAM,KAAK,MAAM,KAAK;AAAA,EACvB;AAAA,EAEA,MAAM,WAAW;AAChB,UAAM,MAAM,UAAU,oBAAoB,KAAK,SAAS,QAAQ;AAChE,UAAM,WAAW,SAAS,SAAS,MAAM,GAAG;AAC5C,UAAM,WAAW,WAAW,SAAS,MAAM,GAAG;AAC9C,UAAM,WAAW,OAAO,SAAS,MAAM,GAAG;AAC1C,UAAM,WAAW,QAAQ,SAAS,MAAM,GAAG;AAAA,EAC5C;AAAA,EAEA,MAAM,SAAS;AACd,UAAM,cAAc,IAAI;AAAA,EACzB;AACD;","names":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { j as ContextCommandData, S as SlashCommandData,
|
|
1
|
+
import { R as RO_ArrayType, k as MessageCommandArgument, p as MessageCommandData, j as ContextCommandData, S as SlashCommandData, v as SlashSubcommandData, w as SlashSubcommandGroupData } from '../../modules.types-BgGFvIsW.js';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import '../client/client.types.js';
|
|
4
4
|
import '../permissions/permissions.types.js';
|
|
5
5
|
import '../client/logger.js';
|
|
6
6
|
|
|
7
|
+
declare function createMessageCommand<const T extends RO_ArrayType<MessageCommandArgument> = undefined>(command: Omit<MessageCommandData<false, T>, "context" | "metadata">): Omit<MessageCommandData<false, T>, "metadata">;
|
|
7
8
|
declare function createSlashCommand(data: Omit<SlashCommandData, "context" | "commandType" | "subcommands" | "subcommandGroups">): SlashCommandData;
|
|
8
9
|
/**
|
|
9
10
|
* @deprecated Use createSlashSubcommand instead
|
|
@@ -18,4 +19,4 @@ declare function createSlashSubcommandGroup(data: Omit<SlashSubcommandGroupData,
|
|
|
18
19
|
declare function createMessageContextCommand(data: Omit<ContextCommandData<"Message">, "commandType">): ContextCommandData<"Message">;
|
|
19
20
|
declare function createUserContextCommand(data: Omit<ContextCommandData<"User">, "commandType">): ContextCommandData<"User">;
|
|
20
21
|
|
|
21
|
-
export { createMessageContextCommand, createSlashCommand, createSlashSubcommand, createSlashSubcommandGroup, createSubcommand, createSubcommandGroup, createUserContextCommand };
|
|
22
|
+
export { createMessageCommand, createMessageContextCommand, createSlashCommand, createSlashSubcommand, createSlashSubcommandGroup, createSubcommand, createSubcommandGroup, createUserContextCommand };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { ApplicationCommandType, Collection } from "discord.js";
|
|
2
|
+
function createMessageCommand(command) {
|
|
3
|
+
return {
|
|
4
|
+
context: "MessageCommand",
|
|
5
|
+
...command
|
|
6
|
+
};
|
|
7
|
+
}
|
|
2
8
|
function createSlashCommand(data) {
|
|
3
9
|
return {
|
|
4
10
|
...data,
|
|
@@ -35,18 +41,21 @@ function createSlashSubcommandGroup(data) {
|
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
function createMessageContextCommand(data) {
|
|
44
|
+
data.data.setType(ApplicationCommandType.Message);
|
|
38
45
|
return {
|
|
39
46
|
...data,
|
|
40
47
|
commandType: ApplicationCommandType.Message
|
|
41
48
|
};
|
|
42
49
|
}
|
|
43
50
|
function createUserContextCommand(data) {
|
|
51
|
+
data.data.setType(ApplicationCommandType.User);
|
|
44
52
|
return {
|
|
45
53
|
...data,
|
|
46
54
|
commandType: ApplicationCommandType.User
|
|
47
55
|
};
|
|
48
56
|
}
|
|
49
57
|
export {
|
|
58
|
+
createMessageCommand,
|
|
50
59
|
createMessageContextCommand,
|
|
51
60
|
createSlashCommand,
|
|
52
61
|
createSlashSubcommand,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/commands/builders.commands.ts"],"sourcesContent":["import {\n\tContextCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n} from \"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/commands/builders.commands.ts"],"sourcesContent":["import {\n\tContextCommandData,\n\tMessageCommandArgument,\n\tMessageCommandData,\n\tRO_ArrayType,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n} from \"#typings\";\nimport { ApplicationCommandType, Collection } from \"discord.js\";\n\nexport function createMessageCommand<\n\tconst T extends RO_ArrayType<MessageCommandArgument> = undefined,\n>(\n\tcommand: Omit<MessageCommandData<false, T>, \"context\" | \"metadata\">\n): Omit<MessageCommandData<false, T>, \"metadata\"> {\n\treturn {\n\t\tcontext: \"MessageCommand\",\n\t\t...command,\n\t};\n}\n\nexport function createSlashCommand(\n\tdata: Omit<SlashCommandData, \"context\" | \"commandType\" | \"subcommands\" | \"subcommandGroups\">\n): SlashCommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashCommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashCommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommand instead\n */\nexport function createSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\nexport function createSlashSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommandGroup instead\n */\nexport function createSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createSlashSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createMessageContextCommand(\n\tdata: Omit<ContextCommandData<\"Message\">, \"commandType\">\n): ContextCommandData<\"Message\"> {\n\tdata.data.setType(ApplicationCommandType.Message);\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.Message,\n\t} satisfies ContextCommandData<\"Message\">;\n}\n\nexport function createUserContextCommand(\n\tdata: Omit<ContextCommandData<\"User\">, \"commandType\">\n): ContextCommandData<\"User\"> {\n\tdata.data.setType(ApplicationCommandType.User);\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.User,\n\t} satisfies ContextCommandData<\"User\">;\n}\n"],"mappings":"AASA,SAAS,wBAAwB,kBAAkB;AAE5C,SAAS,qBAGf,SACiD;AACjD,SAAO;AAAA,IACN,SAAS;AAAA,IACT,GAAG;AAAA,EACJ;AACD;AAEO,SAAS,mBACf,MACmB;AACnB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAKO,SAAS,iBACf,MACsB;AACtB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAEO,SAAS,sBACf,MACsB;AACtB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAKO,SAAS,sBACf,MAC2B;AAC3B,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,IAAI,WAAW;AAAA,EAC7B;AACD;AAEO,SAAS,2BACf,MAC2B;AAC3B,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,IAAI,WAAW;AAAA,EAC7B;AACD;AAEO,SAAS,4BACf,MACgC;AAChC,OAAK,KAAK,QAAQ,uBAAuB,OAAO;AAChD,SAAO;AAAA,IACN,GAAG;AAAA,IACH,aAAa,uBAAuB;AAAA,EACrC;AACD;AAEO,SAAS,yBACf,MAC6B;AAC7B,OAAK,KAAK,QAAQ,uBAAuB,IAAI;AAC7C,SAAO;AAAA,IACN,GAAG;AAAA,IACH,aAAa,uBAAuB;AAAA,EACrC;AACD;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, j as ContextCommandData, S as SlashCommandData,
|
|
2
|
+
export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, j as ContextCommandData, M as MessageCommandArgs, k as MessageCommandArgument, l as MessageCommandArgumentType, m as MessageCommandArgumentTypeMap, n as MessageCommandArgumentsMap, o as MessageCommandBaseData, p as MessageCommandData, q as MessageCommandFlags, r as MessageCommandInteraction, s as MessageCommandMetadata, R as RO_ArrayType, u as ResolveArgType, S as SlashCommandData, v as SlashSubcommandData, w as SlashSubcommandGroupData } from '../../modules.types-BgGFvIsW.js';
|
|
3
3
|
import '../permissions/permissions.types.js';
|
|
4
4
|
import '../client/client.types.js';
|
|
5
5
|
import '../client/logger.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Guild } from 'discord.js';
|
|
2
|
+
import { l as MessageCommandArgumentType, T as TriviousClient, p as MessageCommandData } from '../../../modules.types-BgGFvIsW.js';
|
|
3
|
+
import '../../client/client.types.js';
|
|
4
|
+
import '../../permissions/permissions.types.js';
|
|
5
|
+
import '../../client/logger.js';
|
|
6
|
+
|
|
7
|
+
declare function processPartialMessageCommand(client: TriviousClient, command: MessageCommandData): MessageCommandData<true>;
|
|
8
|
+
type ParseArgumentResult<T> = [result: T] | [result: null, reason: string];
|
|
9
|
+
declare function parseMessageCommandArgument<T = string | number | Date>(dataType: MessageCommandArgumentType, value: string, context: {
|
|
10
|
+
name: string;
|
|
11
|
+
client: TriviousClient;
|
|
12
|
+
guild: Guild | null;
|
|
13
|
+
}, regex?: RegExp): ParseArgumentResult<T>;
|
|
14
|
+
|
|
15
|
+
export { parseMessageCommandArgument, processPartialMessageCommand };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { formatUsage } from "../utility.js";
|
|
2
|
+
const argumentRegex = {
|
|
3
|
+
"duration": /\d+[smhdwy]/,
|
|
4
|
+
"text": /.+?/,
|
|
5
|
+
"snowflake": /<[@#&]!?\d{17,19}>|\d{17,19}/,
|
|
6
|
+
"snowflake/channel": /<#\d{17,19}>|\d{17,19}/,
|
|
7
|
+
"snowflake/role": /<@&\d{17,19}>|\d{17,19}/,
|
|
8
|
+
"snowflake/user": /<@!?\d{17,19}>|\d{17,19}/,
|
|
9
|
+
"timestamp": /\d{10}/,
|
|
10
|
+
"date": /\d{1,2}\/\d{1,2}\/\d{2,4}|\d{2,4}\/\d{1,2}\/\d{1,2}/,
|
|
11
|
+
"number": /[+-]?\d+\.\d*?|\.\d+/
|
|
12
|
+
};
|
|
13
|
+
function processPartialMessageCommand(client, command) {
|
|
14
|
+
let pattern = `^${command.name}`;
|
|
15
|
+
if (command.arguments) {
|
|
16
|
+
for (const argument of command.arguments) {
|
|
17
|
+
const { dataType } = argument;
|
|
18
|
+
let required = argument.required;
|
|
19
|
+
if (required === void 0) {
|
|
20
|
+
command.arguments.find((arg) => arg.name === argument.name).required = true;
|
|
21
|
+
required = true;
|
|
22
|
+
}
|
|
23
|
+
const source = argumentRegex[dataType].source;
|
|
24
|
+
if (!source) continue;
|
|
25
|
+
pattern += required ? `\\s+(${source})` : `(?:\\s+(${source}))?`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
pattern += "$";
|
|
29
|
+
command.metadata = {
|
|
30
|
+
regex: new RegExp(pattern),
|
|
31
|
+
usage: formatUsage(client.trivious.messageCommands?.prefix ?? "?", command)
|
|
32
|
+
};
|
|
33
|
+
return command;
|
|
34
|
+
}
|
|
35
|
+
function parseNumber(value) {
|
|
36
|
+
if (value.trim() === "") return null;
|
|
37
|
+
const num = Number(value);
|
|
38
|
+
return !Number.isNaN(num) ? num : null;
|
|
39
|
+
}
|
|
40
|
+
const durationUnitMap = {
|
|
41
|
+
s: 1,
|
|
42
|
+
m: 60,
|
|
43
|
+
h: 60 * 60,
|
|
44
|
+
d: 60 * 60 * 24,
|
|
45
|
+
w: 60 * 60 * 24 * 7,
|
|
46
|
+
y: 60 * 60 * 24 * 7 * 365
|
|
47
|
+
};
|
|
48
|
+
const snowflakeDataMap = {
|
|
49
|
+
"snowflake/channel": [/(?:<#)?(\d{17,19})>?/, "channels"],
|
|
50
|
+
"snowflake/role": [/(?:<@&)?(\d{17,19})>?/, "roles"],
|
|
51
|
+
"snowflake/user": [/(?:<@!?)?(\d{17,19})>?/, "users"]
|
|
52
|
+
};
|
|
53
|
+
function parseMessageCommandArgument(dataType, value, context, regex) {
|
|
54
|
+
switch (dataType) {
|
|
55
|
+
case "duration": {
|
|
56
|
+
const result = value.match(regex || /(\d+)([smhdwy])/);
|
|
57
|
+
if (!result) return [null, "Invalid input."];
|
|
58
|
+
const [, num, unit] = result;
|
|
59
|
+
const unitMultiplier = durationUnitMap[unit];
|
|
60
|
+
const [number, reason] = parseMessageCommandArgument("number", num, context);
|
|
61
|
+
if (!number) return [null, reason];
|
|
62
|
+
return [Math.ceil(number * unitMultiplier * 1e3)];
|
|
63
|
+
}
|
|
64
|
+
case "number": {
|
|
65
|
+
const number = parseNumber(value);
|
|
66
|
+
if (!number) return [null, "Invalid number."];
|
|
67
|
+
return [number];
|
|
68
|
+
}
|
|
69
|
+
case "snowflake/channel":
|
|
70
|
+
case "snowflake/role":
|
|
71
|
+
case "snowflake/user": {
|
|
72
|
+
const { client, guild } = context;
|
|
73
|
+
const [regex2, manager] = snowflakeDataMap[dataType];
|
|
74
|
+
const [id] = parseMessageCommandArgument("snowflake", value, context, regex2);
|
|
75
|
+
const singular = manager.slice(0, manager.length - 1);
|
|
76
|
+
if (!id) return [null, `Cannot fetch ${singular}: invalid.`];
|
|
77
|
+
const clientTarget = client && manager in client ? client[manager] : null;
|
|
78
|
+
const guildTarget = guild && manager in guild ? guild[manager] : null;
|
|
79
|
+
const object = guildTarget?.cache?.get(id) ?? clientTarget?.cache?.get(id) ?? null;
|
|
80
|
+
if (!object) return [null, `Cannot fetch ${singular}: undefined.`];
|
|
81
|
+
return [object];
|
|
82
|
+
}
|
|
83
|
+
case "snowflake": {
|
|
84
|
+
let isSnowflake = parseNumber(value);
|
|
85
|
+
if (isSnowflake) return [value];
|
|
86
|
+
const result = value.match(regex || /(?:<[@#&]!?)?(\d{17,19})>?/);
|
|
87
|
+
if (!result) return [null, "Invalid input"];
|
|
88
|
+
const id = result[1];
|
|
89
|
+
isSnowflake = parseNumber(id);
|
|
90
|
+
if (!isSnowflake) return [null, "Invalid snowflake or mention."];
|
|
91
|
+
return [id];
|
|
92
|
+
}
|
|
93
|
+
case "text":
|
|
94
|
+
return [String(value)];
|
|
95
|
+
case "date":
|
|
96
|
+
case "timestamp": {
|
|
97
|
+
const date = new Date(value);
|
|
98
|
+
if (Number.isNaN(+date)) return [null, "Invalid timestamp or date passed."];
|
|
99
|
+
return [date];
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
return [null, "Nothing to parse"];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
parseMessageCommandArgument,
|
|
107
|
+
processPartialMessageCommand
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=message.commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/commands/handlers/message.commands.ts"],"sourcesContent":["import { MessageCommandArgumentType, MessageCommandData, TriviousClient } from \"#typings\";\nimport { Guild } from \"discord.js\";\nimport { formatUsage } from \"../utility.js\";\n\nconst argumentRegex: Record<MessageCommandArgumentType, RegExp> = {\n\t\"duration\": /\\d+[smhdwy]/,\n\t\"text\": /.+?/,\n\t\"snowflake\": /<[@#&]!?\\d{17,19}>|\\d{17,19}/,\n\t\"snowflake/channel\": /<#\\d{17,19}>|\\d{17,19}/,\n\t\"snowflake/role\": /<@&\\d{17,19}>|\\d{17,19}/,\n\t\"snowflake/user\": /<@!?\\d{17,19}>|\\d{17,19}/,\n\t\"timestamp\": /\\d{10}/,\n\t\"date\": /\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}|\\d{2,4}\\/\\d{1,2}\\/\\d{1,2}/,\n\t\"number\": /[+-]?\\d+\\.\\d*?|\\.\\d+/,\n};\n\nexport function processPartialMessageCommand(\n\tclient: TriviousClient,\n\tcommand: MessageCommandData\n): MessageCommandData<true> {\n\tlet pattern = `^${command.name}`;\n\tif (command.arguments) {\n\t\tfor (const argument of command.arguments) {\n\t\t\tconst { dataType } = argument;\n\t\t\tlet required = argument.required;\n\t\t\tif (required === undefined) {\n\t\t\t\tcommand.arguments.find((arg) => arg.name === argument.name)!.required = true;\n\t\t\t\trequired = true;\n\t\t\t}\n\t\t\tconst source = argumentRegex[dataType].source;\n\t\t\tif (!source) continue;\n\t\t\tpattern += required ? `\\\\s+(${source})` : `(?:\\\\s+(${source}))?`;\n\t\t}\n\t}\n\tpattern += \"$\";\n\tcommand.metadata = {\n\t\tregex: new RegExp(pattern),\n\t\tusage: formatUsage(client.trivious.messageCommands?.prefix ?? \"?\", command),\n\t};\n\treturn command;\n}\n\nfunction parseNumber(value: string): number | null {\n\tif (value.trim() === \"\") return null;\n\tconst num = Number(value);\n\treturn !Number.isNaN(num) ? num : null;\n}\n\nconst durationUnitMap: Record<string, number> = {\n\ts: 1,\n\tm: 60,\n\th: 60 * 60,\n\td: 60 * 60 * 24,\n\tw: 60 * 60 * 24 * 7,\n\ty: 60 * 60 * 24 * 7 * 365,\n};\nconst snowflakeDataMap: Record<string, [RegExp, \"channels\" | \"roles\" | \"users\"]> = {\n\t\"snowflake/channel\": [/(?:<#)?(\\d{17,19})>?/, \"channels\"],\n\t\"snowflake/role\": [/(?:<@&)?(\\d{17,19})>?/, \"roles\"],\n\t\"snowflake/user\": [/(?:<@!?)?(\\d{17,19})>?/, \"users\"],\n};\ntype ParseArgumentResult<T> = [result: T] | [result: null, reason: string];\nexport function parseMessageCommandArgument<T = string | number | Date>(\n\tdataType: MessageCommandArgumentType,\n\tvalue: string,\n\tcontext: { name: string; client: TriviousClient; guild: Guild | null },\n\tregex?: RegExp\n): ParseArgumentResult<T> {\n\tswitch (dataType) {\n\t\tcase \"duration\": {\n\t\t\tconst result = value.match(regex || /(\\d+)([smhdwy])/);\n\t\t\tif (!result) return [null, \"Invalid input.\"];\n\t\t\tconst [, num, unit] = result;\n\t\t\tconst unitMultiplier = durationUnitMap[unit];\n\t\t\tconst [number, reason] = parseMessageCommandArgument<number>(\"number\", num, context);\n\t\t\tif (!number) return [null, reason!];\n\t\t\treturn [Math.ceil(number * unitMultiplier * 1000) as T];\n\t\t}\n\t\tcase \"number\": {\n\t\t\tconst number = parseNumber(value);\n\t\t\tif (!number) return [null, \"Invalid number.\"];\n\t\t\treturn [number as T];\n\t\t}\n\t\tcase \"snowflake/channel\":\n\t\tcase \"snowflake/role\":\n\t\tcase \"snowflake/user\": {\n\t\t\tconst { client, guild } = context;\n\t\t\tconst [regex, manager] = snowflakeDataMap[dataType];\n\t\t\tconst [id] = parseMessageCommandArgument<string>(\"snowflake\", value, context, regex);\n\t\t\tconst singular = manager.slice(0, manager.length - 1);\n\t\t\tif (!id) return [null, `Cannot fetch ${singular}: invalid.`];\n\t\t\tconst clientTarget =\n\t\t\t\tclient && manager in client ? (client as Record<string, any>)[manager] : null;\n\t\t\tconst guildTarget =\n\t\t\t\tguild && manager in guild ? (guild as Record<string, any>)[manager] : null;\n\t\t\tconst object = guildTarget?.cache?.get(id) ?? clientTarget?.cache?.get(id) ?? null;\n\t\t\tif (!object) return [null, `Cannot fetch ${singular}: undefined.`];\n\t\t\treturn [object as T];\n\t\t}\n\t\tcase \"snowflake\": {\n\t\t\tlet isSnowflake = parseNumber(value);\n\t\t\tif (isSnowflake) return [value as T];\n\t\t\tconst result = value.match(regex || /(?:<[@#&]!?)?(\\d{17,19})>?/);\n\t\t\tif (!result) return [null, \"Invalid input\"];\n\t\t\tconst id = result[1];\n\t\t\tisSnowflake = parseNumber(id);\n\t\t\tif (!isSnowflake) return [null, \"Invalid snowflake or mention.\"];\n\t\t\treturn [id as T];\n\t\t}\n\t\tcase \"text\":\n\t\t\treturn [String(value) as T];\n\t\tcase \"date\":\n\t\tcase \"timestamp\": {\n\t\t\tconst date = new Date(value);\n\t\t\tif (Number.isNaN(+date)) return [null, \"Invalid timestamp or date passed.\"];\n\t\t\treturn [date as T];\n\t\t}\n\t\tdefault:\n\t\t\treturn [null, \"Nothing to parse\"];\n\t}\n}\n"],"mappings":"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","names":["regex"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChatInputCommandInteraction } from 'discord.js';
|
|
2
|
+
import { T as TriviousClient, S as SlashCommandData } from '../../../modules.types-BgGFvIsW.js';
|
|
3
|
+
import '../../client/client.types.js';
|
|
4
|
+
import '../../permissions/permissions.types.js';
|
|
5
|
+
import '../../client/logger.js';
|
|
6
|
+
|
|
7
|
+
declare function handleSlashCommand(client: TriviousClient, command: SlashCommandData, interaction: ChatInputCommandInteraction): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { handleSlashCommand };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { interactionReply } from "../methods.commands.js";
|
|
2
|
+
async function handleFlags(interaction, flags) {
|
|
3
|
+
if (flags?.includes("Cached") && !interaction.inCachedGuild()) return;
|
|
4
|
+
if (flags?.includes("ExpectModal")) return;
|
|
5
|
+
if (flags?.includes("DeferReply")) {
|
|
6
|
+
await interactionReply({
|
|
7
|
+
interaction,
|
|
8
|
+
flags,
|
|
9
|
+
replyPayload: { content: "Processing command..." }
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function handleSlashCommand(client, command, interaction) {
|
|
14
|
+
const { options } = interaction;
|
|
15
|
+
const subcommandGroup = options.getSubcommandGroup(false);
|
|
16
|
+
const subcommand = options.getSubcommand(false);
|
|
17
|
+
if (!subcommandGroup && !subcommand) {
|
|
18
|
+
await handleFlags(interaction, command.flags);
|
|
19
|
+
if ("run" in command && command.run) {
|
|
20
|
+
try {
|
|
21
|
+
await command.run(client, interaction);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error(err);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (subcommandGroup && command.subcommandGroups && subcommand) {
|
|
29
|
+
const foundGroup = command.subcommandGroups.get(subcommandGroup);
|
|
30
|
+
if (!foundGroup) {
|
|
31
|
+
await interactionReply({
|
|
32
|
+
interaction,
|
|
33
|
+
flags: ["EphemeralReply"],
|
|
34
|
+
replyPayload: {
|
|
35
|
+
content: "Subcommand group is outdated, inactive, or does not have a handler!"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const foundSubcommand = foundGroup.subcommands.get(subcommand);
|
|
41
|
+
if (!foundSubcommand) {
|
|
42
|
+
await interactionReply({
|
|
43
|
+
interaction,
|
|
44
|
+
flags: ["EphemeralReply"],
|
|
45
|
+
replyPayload: { content: "Subcommand is outdated, inactive, or does not have a handler!" }
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await handleFlags(interaction, foundSubcommand.flags || command.flags);
|
|
50
|
+
return await foundSubcommand.execute(client, interaction);
|
|
51
|
+
} else if (subcommand && command.subcommands) {
|
|
52
|
+
const foundSubcommand = command.subcommands.get(subcommand);
|
|
53
|
+
if (!foundSubcommand) {
|
|
54
|
+
await interactionReply({
|
|
55
|
+
interaction,
|
|
56
|
+
flags: ["EphemeralReply"],
|
|
57
|
+
replyPayload: { content: "Subcommand is outdated, inactive, or does not have a handler!" }
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await handleFlags(interaction, foundSubcommand.flags || command.flags);
|
|
62
|
+
return await foundSubcommand.execute(client, interaction);
|
|
63
|
+
} else {
|
|
64
|
+
await interactionReply({
|
|
65
|
+
interaction,
|
|
66
|
+
flags: ["EphemeralReply"],
|
|
67
|
+
replyPayload: { content: "Command is outdated, inactive, or does not have a handler!" }
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
handleSlashCommand
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=slash.commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/commands/handlers/slash.commands.ts"],"sourcesContent":["import { CommandFlags, SlashCommandData, TriviousClient } from \"#typings\";\nimport { ChatInputCommandInteraction } from \"discord.js\";\nimport { interactionReply } from \"../methods.commands.js\";\n\nasync function handleFlags(interaction: ChatInputCommandInteraction, flags?: CommandFlags[]) {\n\tif (flags?.includes(\"Cached\") && !interaction.inCachedGuild()) return;\n\tif (flags?.includes(\"ExpectModal\")) return;\n\tif (flags?.includes(\"DeferReply\")) {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: flags,\n\t\t\treplyPayload: { content: \"Processing command...\" },\n\t\t});\n\t}\n}\n\nexport async function handleSlashCommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData,\n\tinteraction: ChatInputCommandInteraction\n) {\n\tconst { options } = interaction;\n\n\tconst subcommandGroup = options.getSubcommandGroup(false);\n\tconst subcommand = options.getSubcommand(false);\n\n\tif (!subcommandGroup && !subcommand) {\n\t\tawait handleFlags(interaction, command.flags);\n\n\t\tif (\"run\" in command && command.run) {\n\t\t\ttry {\n\t\t\t\tawait command.run(client, interaction);\n\t\t\t} catch (err: any) {\n\t\t\t\tconsole.error(err);\n\t\t\t}\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (subcommandGroup && command.subcommandGroups && subcommand) {\n\t\tconst foundGroup = command.subcommandGroups.get(subcommandGroup);\n\t\tif (!foundGroup) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: {\n\t\t\t\t\tcontent: \"Subcommand group is outdated, inactive, or does not have a handler!\",\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst foundSubcommand = foundGroup.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else if (subcommand && command.subcommands) {\n\t\tconst foundSubcommand = command.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: [\"EphemeralReply\"],\n\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t});\n\t}\n}\n"],"mappings":"AAEA,SAAS,wBAAwB;AAEjC,eAAe,YAAY,aAA0C,OAAwB;AAC5F,MAAI,OAAO,SAAS,QAAQ,KAAK,CAAC,YAAY,cAAc,EAAG;AAC/D,MAAI,OAAO,SAAS,aAAa,EAAG;AACpC,MAAI,OAAO,SAAS,YAAY,GAAG;AAClC,UAAM,iBAAiB;AAAA,MACtB;AAAA,MACA;AAAA,MACA,cAAc,EAAE,SAAS,wBAAwB;AAAA,IAClD,CAAC;AAAA,EACF;AACD;AAEA,eAAsB,mBACrB,QACA,SACA,aACC;AACD,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,kBAAkB,QAAQ,mBAAmB,KAAK;AACxD,QAAM,aAAa,QAAQ,cAAc,KAAK;AAE9C,MAAI,CAAC,mBAAmB,CAAC,YAAY;AACpC,UAAM,YAAY,aAAa,QAAQ,KAAK;AAE5C,QAAI,SAAS,WAAW,QAAQ,KAAK;AACpC,UAAI;AACH,cAAM,QAAQ,IAAI,QAAQ,WAAW;AAAA,MACtC,SAAS,KAAU;AAClB,gBAAQ,MAAM,GAAG;AAAA,MAClB;AAAA,IACD;AAEA;AAAA,EACD;AAEA,MAAI,mBAAmB,QAAQ,oBAAoB,YAAY;AAC9D,UAAM,aAAa,QAAQ,iBAAiB,IAAI,eAAe;AAC/D,QAAI,CAAC,YAAY;AAChB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA,OAAO,CAAC,gBAAgB;AAAA,QACxB,cAAc;AAAA,UACb,SAAS;AAAA,QACV;AAAA,MACD,CAAC;AACD;AAAA,IACD;AAEA,UAAM,kBAAkB,WAAW,YAAY,IAAI,UAAU;AAC7D,QAAI,CAAC,iBAAiB;AACrB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA,OAAO,CAAC,gBAAgB;AAAA,QACxB,cAAc,EAAE,SAAS,gEAAgE;AAAA,MAC1F,CAAC;AACD;AAAA,IACD;AAEA,UAAM,YAAY,aAAa,gBAAgB,SAAS,QAAQ,KAAK;AACrE,WAAO,MAAM,gBAAgB,QAAQ,QAAQ,WAAW;AAAA,EACzD,WAAW,cAAc,QAAQ,aAAa;AAC7C,UAAM,kBAAkB,QAAQ,YAAY,IAAI,UAAU;AAC1D,QAAI,CAAC,iBAAiB;AACrB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA,OAAO,CAAC,gBAAgB;AAAA,QACxB,cAAc,EAAE,SAAS,gEAAgE;AAAA,MAC1F,CAAC;AACD;AAAA,IACD;AAEA,UAAM,YAAY,aAAa,gBAAgB,SAAS,QAAQ,KAAK;AACrE,WAAO,MAAM,gBAAgB,QAAQ,QAAQ,WAAW;AAAA,EACzD,OAAO;AACN,UAAM,iBAAiB;AAAA,MACtB;AAAA,MACA,OAAO,CAAC,gBAAgB;AAAA,MACxB,cAAc,EAAE,SAAS,6DAA6D;AAAA,IACvF,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Interaction, CacheType, InteractionReplyOptions, InteractionResponse, InteractionEditReplyOptions, Message, MessagePayload } from 'discord.js';
|
|
2
|
+
import { c as CommandFlags } from '../../modules.types-BgGFvIsW.js';
|
|
3
3
|
import '../client/client.types.js';
|
|
4
4
|
import '../permissions/permissions.types.js';
|
|
5
5
|
import '../client/logger.js';
|
|
@@ -19,6 +19,5 @@ declare function interactionReply(options: {
|
|
|
19
19
|
replyPayload: MessagePayload;
|
|
20
20
|
flags?: (CommandFlags | "FollowUp")[];
|
|
21
21
|
}): Promise<InteractionResponse<boolean> | Message<boolean>>;
|
|
22
|
-
declare function handleSlashCommand(client: TriviousClient, command: SlashCommandData, interaction: ChatInputCommandInteraction): Promise<void>;
|
|
23
22
|
|
|
24
|
-
export {
|
|
23
|
+
export { interactionReply };
|
|
@@ -9,77 +9,7 @@ async function interactionReply(options) {
|
|
|
9
9
|
}
|
|
10
10
|
return await interaction.reply(payload);
|
|
11
11
|
}
|
|
12
|
-
async function handleFlags(interaction, flags) {
|
|
13
|
-
if (flags?.includes("Cached") && !interaction.inCachedGuild()) return;
|
|
14
|
-
if (flags?.includes("ExpectModal")) return;
|
|
15
|
-
if (flags?.includes("DeferReply")) {
|
|
16
|
-
await interactionReply({
|
|
17
|
-
interaction,
|
|
18
|
-
flags,
|
|
19
|
-
replyPayload: { content: "Processing command..." }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function handleSlashCommand(client, command, interaction) {
|
|
24
|
-
const { options } = interaction;
|
|
25
|
-
const subcommandGroup = options.getSubcommandGroup(false);
|
|
26
|
-
const subcommand = options.getSubcommand(false);
|
|
27
|
-
if (!subcommandGroup && !subcommand) {
|
|
28
|
-
await handleFlags(interaction, command.flags);
|
|
29
|
-
if ("run" in command && command.run) {
|
|
30
|
-
try {
|
|
31
|
-
await command.run(client, interaction);
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.error(err);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (subcommandGroup && command.subcommandGroups && subcommand) {
|
|
39
|
-
const foundGroup = command.subcommandGroups.get(subcommandGroup);
|
|
40
|
-
if (!foundGroup) {
|
|
41
|
-
await interactionReply({
|
|
42
|
-
interaction,
|
|
43
|
-
flags: ["EphemeralReply"],
|
|
44
|
-
replyPayload: {
|
|
45
|
-
content: "Subcommand group is outdated, inactive, or does not have a handler!"
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const foundSubcommand = foundGroup.subcommands.get(subcommand);
|
|
51
|
-
if (!foundSubcommand) {
|
|
52
|
-
await interactionReply({
|
|
53
|
-
interaction,
|
|
54
|
-
flags: ["EphemeralReply"],
|
|
55
|
-
replyPayload: { content: "Subcommand is outdated, inactive, or does not have a handler!" }
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
await handleFlags(interaction, foundSubcommand.flags || command.flags);
|
|
60
|
-
return await foundSubcommand.execute(client, interaction);
|
|
61
|
-
} else if (subcommand && command.subcommands) {
|
|
62
|
-
const foundSubcommand = command.subcommands.get(subcommand);
|
|
63
|
-
if (!foundSubcommand) {
|
|
64
|
-
await interactionReply({
|
|
65
|
-
interaction,
|
|
66
|
-
flags: ["EphemeralReply"],
|
|
67
|
-
replyPayload: { content: "Subcommand is outdated, inactive, or does not have a handler!" }
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
await handleFlags(interaction, foundSubcommand.flags || command.flags);
|
|
72
|
-
return await foundSubcommand.execute(client, interaction);
|
|
73
|
-
} else {
|
|
74
|
-
await interactionReply({
|
|
75
|
-
interaction,
|
|
76
|
-
flags: ["EphemeralReply"],
|
|
77
|
-
replyPayload: { content: "Command is outdated, inactive, or does not have a handler!" }
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
12
|
export {
|
|
82
|
-
handleSlashCommand,
|
|
83
13
|
interactionReply
|
|
84
14
|
};
|
|
85
15
|
//# sourceMappingURL=methods.commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/commands/methods.commands.ts"],"sourcesContent":["import { CommandFlags
|
|
1
|
+
{"version":3,"sources":["../../../src/features/commands/methods.commands.ts"],"sourcesContent":["import { CommandFlags } from \"#typings\";\nimport {\n\tCacheType,\n\tInteraction,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tInteractionResponse,\n\tMessage,\n\tMessagePayload,\n} from \"discord.js\";\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionEditReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean> | Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions | InteractionEditReplyOptions | MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}) {\n\tconst { interaction, replyPayload, flags } = options;\n\tif (!(\"reply\" in interaction)) return;\n\n\tconst payload = replyPayload as InteractionReplyOptions;\n\tif (flags?.includes(\"EphemeralReply\")) payload.flags = [\"Ephemeral\"];\n\n\tif (interaction.deferred || interaction.replied) {\n\t\tif (flags?.includes(\"FollowUp\")) return await interaction.followUp(payload);\n\t\treturn await interaction.editReply(payload as InteractionEditReplyOptions);\n\t}\n\n\treturn await interaction.reply(payload);\n}\n"],"mappings":"AA6BA,eAAsB,iBAAiB,SAIpC;AACF,QAAM,EAAE,aAAa,cAAc,MAAM,IAAI;AAC7C,MAAI,EAAE,WAAW,aAAc;AAE/B,QAAM,UAAU;AAChB,MAAI,OAAO,SAAS,gBAAgB,EAAG,SAAQ,QAAQ,CAAC,WAAW;AAEnE,MAAI,YAAY,YAAY,YAAY,SAAS;AAChD,QAAI,OAAO,SAAS,UAAU,EAAG,QAAO,MAAM,YAAY,SAAS,OAAO;AAC1E,WAAO,MAAM,YAAY,UAAU,OAAsC;AAAA,EAC1E;AAEA,SAAO,MAAM,YAAY,MAAM,OAAO;AACvC;","names":[]}
|