refactor(subcommandgroup): required default to false (#7217)

This commit is contained in:
Parbez
2022-01-17 21:16:31 +05:30
committed by GitHub
parent 26a9dc3206
commit 6112767128
3 changed files with 7 additions and 7 deletions

View File

@@ -116,10 +116,10 @@ class CommandInteractionOptionResolver {
/**
* Gets the selected subcommand group.
* @param {boolean} [required=true] Whether to throw an error if there is no subcommand group.
* @param {boolean} [required=false] Whether to throw an error if there is no subcommand group.
* @returns {?string} The name of the selected subcommand group, or null if not set and not required.
*/
getSubcommandGroup(required = true) {
getSubcommandGroup(required = false) {
if (required && !this._group) {
throw new TypeError('COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND_GROUP');
}

View File

@@ -687,8 +687,8 @@ export interface ApplicationCommandInteractionOptionResolver<Cached extends Cach
extends CommandInteractionOptionResolver<Cached> {
getSubcommand(required?: true): string;
getSubcommand(required: boolean): string | null;
getSubcommandGroup(required?: true): string;
getSubcommandGroup(required: boolean): string | null;
getSubcommandGroup(required: true): string;
getSubcommandGroup(required?: boolean): string | null;
getBoolean(name: string, required: true): boolean;
getBoolean(name: string, required?: boolean): boolean | null;
getChannel(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['channel']>;
@@ -762,8 +762,8 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
public getSubcommand(required?: true): string;
public getSubcommand(required: boolean): string | null;
public getSubcommandGroup(required?: true): string;
public getSubcommandGroup(required: boolean): string | null;
public getSubcommandGroup(required: true): string;
public getSubcommandGroup(required?: boolean): string | null;
public getBoolean(name: string, required: true): boolean;
public getBoolean(name: string, required?: boolean): boolean | null;
public getChannel(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['channel']>;

View File

@@ -1119,8 +1119,8 @@ client.on('interactionCreate', async interaction => {
expectType<string | null>(interaction.options.getSubcommand(booleanValue));
expectType<string | null>(interaction.options.getSubcommand(false));
expectType<string>(interaction.options.getSubcommandGroup());
expectType<string>(interaction.options.getSubcommandGroup(true));
expectType<string | null>(interaction.options.getSubcommandGroup());
expectType<string | null>(interaction.options.getSubcommandGroup(booleanValue));
expectType<string | null>(interaction.options.getSubcommandGroup(false));
}