From 52fda11ba28742652851ad1dacf18996b44d3261 Mon Sep 17 00:00:00 2001 From: bsian03 Date: Wed, 29 Jul 2020 17:36:26 +0100 Subject: [PATCH] feat(CommandEnvironment): Add usedLabel prop (#94) * Add used label prop to CommandEnvironment * Add missing doc --- src/Core/Command/CommandEnvironment.js | 6 +++++- src/Core/CommandDispatcher.js | 2 +- types/Core/Command/CommandEnvironment.ts | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Core/Command/CommandEnvironment.js b/src/Core/Command/CommandEnvironment.js index e07bc441..8e591e76 100644 --- a/src/Core/Command/CommandEnvironment.js +++ b/src/Core/Command/CommandEnvironment.js @@ -17,6 +17,7 @@ import { COMMAND_EXECUTION_TYPES } from '../../Utility/Constants/AxonEnums'; * @prop {GuildConfig} guildConfig - The GuildConfig data-structure with all DB saved settings * @prop {String} prefix - The prefix used for this command * @prop {String} command - The full label of the command being executed + * @prop {String} usedCommandLabel - The used label of the command being executed * @prop {COMMAND_EXECUTION_TYPES} executionType - Execution type: admin, owner, regular */ class CommandEnvironment { @@ -40,6 +41,7 @@ class CommandEnvironment { this.prefix = data.prefix || null; this.command = data.command !== undefined ? data.command.fullLabel : null; + this.usedLabel = null; this.guildConfig = data.guildConfig || null; @@ -96,11 +98,13 @@ class CommandEnvironment { * Set the command label from the command object * * @param {Command} command + * @param {String} usedLabel * @returns {CommandEnvironment} This CommandEnvironment * @memberof CommandEnvironment */ - setCommand(command) { + setCommand(command, usedLabel) { this.command = command.fullLabel; + this.usedLabel = usedLabel; return this; } diff --git a/src/Core/CommandDispatcher.js b/src/Core/CommandDispatcher.js index 837837ee..3e96f8cc 100644 --- a/src/Core/CommandDispatcher.js +++ b/src/Core/CommandDispatcher.js @@ -131,7 +131,7 @@ class CommandDispatcher { if (!command) { // command doesn't exist or not globally enabled return; } - env.setCommand(command); + env.setCommand(command, label); env.resolveArgs(null, args.join(' ') ); /* Send help for the resolved command */ diff --git a/types/Core/Command/CommandEnvironment.ts b/types/Core/Command/CommandEnvironment.ts index 59c4296e..c37a5365 100644 --- a/types/Core/Command/CommandEnvironment.ts +++ b/types/Core/Command/CommandEnvironment.ts @@ -13,6 +13,7 @@ export declare class CommandEnvironment; public args: string[]; public prefix: string; @@ -53,11 +54,11 @@ export declare class CommandEnvironment