Skip to content

Commit 52fda11

Browse files
authored
feat(CommandEnvironment): Add usedLabel prop (#94)
* Add used label prop to CommandEnvironment * Add missing doc
1 parent 4768d90 commit 52fda11

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Core/Command/CommandEnvironment.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { COMMAND_EXECUTION_TYPES } from '../../Utility/Constants/AxonEnums';
1717
* @prop {GuildConfig} guildConfig - The GuildConfig data-structure with all DB saved settings
1818
* @prop {String} prefix - The prefix used for this command
1919
* @prop {String} command - The full label of the command being executed
20+
* @prop {String} usedCommandLabel - The used label of the command being executed
2021
* @prop {COMMAND_EXECUTION_TYPES} executionType - Execution type: admin, owner, regular
2122
*/
2223
class CommandEnvironment {
@@ -40,6 +41,7 @@ class CommandEnvironment {
4041
this.prefix = data.prefix || null;
4142

4243
this.command = data.command !== undefined ? data.command.fullLabel : null;
44+
this.usedLabel = null;
4345

4446
this.guildConfig = data.guildConfig || null;
4547

@@ -96,11 +98,13 @@ class CommandEnvironment {
9698
* Set the command label from the command object
9799
*
98100
* @param {Command} command
101+
* @param {String} usedLabel
99102
* @returns {CommandEnvironment} This CommandEnvironment
100103
* @memberof CommandEnvironment
101104
*/
102-
setCommand(command) {
105+
setCommand(command, usedLabel) {
103106
this.command = command.fullLabel;
107+
this.usedLabel = usedLabel;
104108
return this;
105109
}
106110

src/Core/CommandDispatcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CommandDispatcher {
131131
if (!command) { // command doesn't exist or not globally enabled
132132
return;
133133
}
134-
env.setCommand(command);
134+
env.setCommand(command, label);
135135
env.resolveArgs(null, args.join(' ') );
136136

137137
/* Send help for the resolved command */

types/Core/Command/CommandEnvironment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export declare class CommandEnvironment<T extends LibTextableChannel = LibTextab
1313
/** The raw message content */
1414
public raw: string;
1515
public command: string;
16+
public usedLabel: string;
1617
public msg: LibMessage<T>;
1718
public args: string[];
1819
public prefix: string;
@@ -53,11 +54,11 @@ export declare class CommandEnvironment<T extends LibTextableChannel = LibTextab
5354
public setGuildConfig(guildConfig: GuildConfig): this;
5455

5556
/**
56-
* Set the command lavel from the command object
57+
* Set the command label from the command object
5758
* @returns This CommandEnvironment
5859
* @memberof CommandEnvironment
5960
*/
60-
public setCommand(command: Command): CommandEnvironment;
61+
public setCommand(command: Command, usedLabel: string): CommandEnvironment;
6162

6263
/**
6364
* Resolve the argument from the args string.

0 commit comments

Comments
 (0)