Skip to content

Commit 70e1465

Browse files
authoredMay 2, 2024··
feat(command): add rawName property (#751)
* feat(command): add rawName property * refactor: single nullish coalescing
1 parent b923b3e commit 70e1465

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎src/lib/structures/Command.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ const ChannelTypes = Object.values(ChannelType).filter((type) => typeof type ===
3434
const GuildChannelTypes = ChannelTypes.filter((type) => type !== ChannelType.DM && type !== ChannelType.GroupDM) as readonly ChannelType[];
3535

3636
export class Command<PreParseReturn = Args, Options extends Command.Options = Command.Options> extends AliasPiece<Options, 'commands'> {
37+
/**
38+
* The raw name of the command as provided through file name or constructor options.
39+
*
40+
* This is exactly what is set by the developer, completely unmodified internally by the framework.
41+
* Unlike the `name` which gets lowercased for storing it uniquely in the {@link CommandStore}.
42+
*/
43+
public rawName: string;
44+
3745
/**
3846
* A basic summary about the command
3947
* @since 1.0.0
@@ -97,7 +105,10 @@ export class Command<PreParseReturn = Args, Options extends Command.Options = Co
97105
* @param options Optional Command settings.
98106
*/
99107
public constructor(context: Command.LoaderContext, options: Options = {} as Options) {
100-
super(context, { ...options, name: (options.name ?? context.name).toLowerCase() });
108+
const name = options.name ?? context.name;
109+
super(context, { ...options, name: name.toLowerCase() });
110+
111+
this.rawName = name;
101112
this.description = options.description ?? '';
102113
this.detailedDescription = options.detailedDescription ?? '';
103114
this.strategy = new FlagUnorderedStrategy(options);

0 commit comments

Comments
 (0)
Please sign in to comment.