From 6112767128a664f32205425f52ba52220d57834f Mon Sep 17 00:00:00 2001 From: Parbez Date: Mon, 17 Jan 2022 21:16:31 +0530 Subject: [PATCH] refactor(subcommandgroup): required default to false (#7217) --- .../src/structures/CommandInteractionOptionResolver.js | 4 ++-- packages/discord.js/typings/index.d.ts | 8 ++++---- packages/discord.js/typings/index.test-d.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js index 71d19696c..bcd28f063 100644 --- a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js +++ b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js @@ -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'); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index b65a15566..671285462 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -687,8 +687,8 @@ export interface ApplicationCommandInteractionOptionResolver { 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['channel']>; @@ -762,8 +762,8 @@ export class CommandInteractionOptionResolver['channel']>; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index c84aa84e9..f8e3ceab9 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -1119,8 +1119,8 @@ client.on('interactionCreate', async interaction => { expectType(interaction.options.getSubcommand(booleanValue)); expectType(interaction.options.getSubcommand(false)); - expectType(interaction.options.getSubcommandGroup()); expectType(interaction.options.getSubcommandGroup(true)); + expectType(interaction.options.getSubcommandGroup()); expectType(interaction.options.getSubcommandGroup(booleanValue)); expectType(interaction.options.getSubcommandGroup(false)); }