Skip to content

Commit

Permalink
feat: support generateUnderscoreLessAliases for command options (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfrangu authored Mar 20, 2022
1 parent 7ef7ac9 commit f1d5c21
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
this.aliases = [...this.aliases, ...dashLessAliases];
}

if (options.generateUnderscoreLessAliases) {
const underscoreLessAliases = [];
if (this.name.includes('_')) underscoreLessAliases.push(this.name.replace(/_/g, ''));
for (const alias of this.aliases) if (alias.includes('_')) underscoreLessAliases.push(alias.replace(/_/g, ''));

this.aliases = [...this.aliases, ...underscoreLessAliases];
}

this.preconditions = new PreconditionContainerArray(options.preconditions);
this.parseConstructorPreConditions(options);

Expand Down Expand Up @@ -587,6 +595,13 @@ export interface CommandOptions extends AliasPiece.Options, FlagStrategyOptions
*/
generateDashLessAliases?: boolean;

/**
* Whether to add aliases for commands with underscores in them
* @since 3.0.0
* @default false
*/
generateUnderscoreLessAliases?: boolean;

/**
* The description for the command.
* @since 1.0.0
Expand Down

0 comments on commit f1d5c21

Please sign in to comment.