From c3ca8bbee6603f66addafeb17b4df680e7d6f17c Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 28 Mar 2024 17:05:59 +0200 Subject: [PATCH] Upgrades Upgraded command parser package Added aliases to commands Added global help flag --- package.json | 2 +- src/client/components/MusicPlayer.ts | 2 +- src/client/components/commands/Queue.ts | 1 + src/client/components/commands/Request.ts | 1 + src/client/components/commands/Search.ts | 1 + src/client/components/commands/Volume.ts | 1 + src/client/components/observers/CommandHandler.ts | 10 ++++++++++ yarn.lock | 10 +++++----- 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c8189a5..f8d2a8f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "@discordjs/opus": "^0.9.0", "@discordjs/voice": "^0.16.1", - "@navy.gif/commandparser": "^1.6.6", + "@navy.gif/commandparser": "^1.6.7", "@navy.gif/logger": "^2.5.4", "@navy.gif/timestring": "^6.0.6", "@types/node": "^20.11.30", diff --git a/src/client/components/MusicPlayer.ts b/src/client/components/MusicPlayer.ts index e1e6ef1..0b68b7d 100644 --- a/src/client/components/MusicPlayer.ts +++ b/src/client/components/MusicPlayer.ts @@ -319,7 +319,7 @@ class MusicPlayer implements Initialisable get queue () { - return Object.freeze(this.#queue); + return this.#queue; } } diff --git a/src/client/components/commands/Queue.ts b/src/client/components/commands/Queue.ts index bc4e247..e0fbf6d 100644 --- a/src/client/components/commands/Queue.ts +++ b/src/client/components/commands/Queue.ts @@ -9,6 +9,7 @@ class QueueCommand extends Command { super(client, { name: 'queue', + aliases: [ 'q' ], options: [{ name: 'artist', flag: true diff --git a/src/client/components/commands/Request.ts b/src/client/components/commands/Request.ts index 2b7b2de..1a36530 100644 --- a/src/client/components/commands/Request.ts +++ b/src/client/components/commands/Request.ts @@ -11,6 +11,7 @@ class RequestCommand extends Command { super(client, { name: 'request', + aliases: [ 'r', 'req' ], guildOnly: true, sameVc: true, showUsage: true, diff --git a/src/client/components/commands/Search.ts b/src/client/components/commands/Search.ts index 5cee46c..027a6ac 100644 --- a/src/client/components/commands/Search.ts +++ b/src/client/components/commands/Search.ts @@ -9,6 +9,7 @@ class SearchCommand extends Command { super(client, { name: 'search', + aliases: [ 's' ], showUsage: true, options: [{ name: 'keyword', diff --git a/src/client/components/commands/Volume.ts b/src/client/components/commands/Volume.ts index 666e7b4..7627a54 100644 --- a/src/client/components/commands/Volume.ts +++ b/src/client/components/commands/Volume.ts @@ -9,6 +9,7 @@ class VolumeCommand extends Command { super(client, { name: 'volume', + aliases: [ 'v', 'vol' ], options: [ { name: 'volume', diff --git a/src/client/components/observers/CommandHandler.ts b/src/client/components/observers/CommandHandler.ts index dd4befb..6d3695a 100644 --- a/src/client/components/observers/CommandHandler.ts +++ b/src/client/components/observers/CommandHandler.ts @@ -30,6 +30,13 @@ class CommandHandler extends Observer commands: this.client.commands.values(), prefix: client.prefix, resolver: client.resolver, + globalFlags: [{ + name: 'help', + flag: true, + valueOptional: true, + defaultValue: true, + type: OptionType.BOOLEAN + }], debug: false }); @@ -120,6 +127,9 @@ class CommandHandler extends Observer }); } + if (rest.globalFlags.help) + return this.#showUsage(message, command as Command); + if ((command as Command).showUsage && !Object.keys(rest.args).length && !rest.subcommand && !rest.subcommandGroup) return this.#showUsage(message, command as Command); diff --git a/yarn.lock b/yarn.lock index 24b9530..10330f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1628,10 +1628,10 @@ __metadata: languageName: node linkType: hard -"@navy.gif/commandparser@npm:^1.6.6": - version: 1.6.6 - resolution: "@navy.gif/commandparser@npm:1.6.6" - checksum: 10/1020ef32bd3b2b2e75dbbbf4814829765ec354ccac1c980978b49ebf2a6bc94cc7031691d2aa275ad98781027aa5cabe7bede8aecbd2d5a3bf8a48440b8befdf +"@navy.gif/commandparser@npm:^1.6.7": + version: 1.6.7 + resolution: "@navy.gif/commandparser@npm:1.6.7" + checksum: 10/2f3ac85ca0d7168af96fd5d03ff85e00949e8f02ff7ac409e01f492c9712442723df536103897bed7d3c3091066525e78254e36591e49d1a9cade16f472383e9 languageName: node linkType: hard @@ -3577,7 +3577,7 @@ __metadata: "@babel/preset-typescript": "npm:^7.24.1" "@discordjs/opus": "npm:^0.9.0" "@discordjs/voice": "npm:^0.16.1" - "@navy.gif/commandparser": "npm:^1.6.6" + "@navy.gif/commandparser": "npm:^1.6.7" "@navy.gif/logger": "npm:^2.5.4" "@navy.gif/timestring": "npm:^6.0.6" "@types/babel__core": "npm:^7"