Skip to content

Commit

Permalink
fix(Command): parentCategory failing with fullCategory.length === 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet authored and favna committed Nov 18, 2023
1 parent 95ccc5d commit 04bc519
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class Command<PreParseReturn = Args, Options extends Command.Options = Co
* @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.
*/
public get category(): string | null {
return this.fullCategory.length > 0 ? this.fullCategory[0] : null;
return this.fullCategory.at(0) ?? null;
}

/**
Expand All @@ -166,7 +166,7 @@ export class Command<PreParseReturn = Args, Options extends Command.Options = Co
* @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.
*/
public get subCategory(): string | null {
return this.fullCategory.length > 1 ? this.fullCategory[1] : null;
return this.fullCategory.at(1) ?? null;
}

/**
Expand All @@ -178,7 +178,7 @@ export class Command<PreParseReturn = Args, Options extends Command.Options = Co
* @note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.
*/
public get parentCategory(): string | null {
return this.fullCategory.length > 1 ? this.fullCategory[this.fullCategory.length - 1] : null;
return this.fullCategory.at(-1) ?? null;
}

/**
Expand Down

0 comments on commit 04bc519

Please sign in to comment.