Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(command): add rawName property #751

Merged
merged 2 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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