Skip to content

Commit

Permalink
feat(command): add rawName property (#751)
Browse files Browse the repository at this point in the history
* feat(command): add rawName property

* refactor: single nullish coalescing
  • Loading branch information
favna committed May 2, 2024
1 parent b923b3e commit 70e1465
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const ChannelTypes = Object.values(ChannelType).filter((type) => typeof type ===
const GuildChannelTypes = ChannelTypes.filter((type) => type !== ChannelType.DM && type !== ChannelType.GroupDM) as readonly ChannelType[];

export class Command<PreParseReturn = Args, Options extends Command.Options = Command.Options> extends AliasPiece<Options, 'commands'> {
/**
* The raw name of the command as provided through file name or constructor options.
*
* This is exactly what is set by the developer, completely unmodified internally by the framework.
* Unlike the `name` which gets lowercased for storing it uniquely in the {@link CommandStore}.
*/
public rawName: string;

/**
* A basic summary about the command
* @since 1.0.0
Expand Down Expand Up @@ -97,7 +105,10 @@ export class Command<PreParseReturn = Args, Options extends Command.Options = Co
* @param options Optional Command settings.
*/
public constructor(context: Command.LoaderContext, options: Options = {} as Options) {
super(context, { ...options, name: (options.name ?? context.name).toLowerCase() });
const name = options.name ?? context.name;
super(context, { ...options, name: name.toLowerCase() });

this.rawName = name;
this.description = options.description ?? '';
this.detailedDescription = options.detailedDescription ?? '';
this.strategy = new FlagUnorderedStrategy(options);
Expand Down

0 comments on commit 70e1465

Please sign in to comment.