mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
refactor(subcommandgroup): required default to false (#7217)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
8
packages/discord.js/typings/index.d.ts
vendored
8
packages/discord.js/typings/index.d.ts
vendored
@@ -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']>;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user