mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: remove required from getMember (#7188)
This commit is contained in:
@@ -196,12 +196,11 @@ class CommandInteractionOptionResolver {
|
||||
/**
|
||||
* Gets a member option.
|
||||
* @param {string} name The name of the option.
|
||||
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
|
||||
* @returns {?(GuildMember|APIGuildMember)}
|
||||
* The value of the option, or null if not set and not required.
|
||||
* The value of the option, or null if the user is not present in the guild or the option is not set.
|
||||
*/
|
||||
getMember(name, required = false) {
|
||||
const option = this._getTypedOption(name, 'USER', ['member'], required);
|
||||
getMember(name) {
|
||||
const option = this._getTypedOption(name, 'USER', ['member'], false);
|
||||
return option?.member ?? null;
|
||||
}
|
||||
|
||||
|
||||
7
packages/discord.js/typings/index.d.ts
vendored
7
packages/discord.js/typings/index.d.ts
vendored
@@ -33,7 +33,6 @@ import {
|
||||
APIApplicationCommandPermission,
|
||||
APIAuditLogChange,
|
||||
APIButtonComponent,
|
||||
APIChannel,
|
||||
APIEmbed,
|
||||
APIEmoji,
|
||||
APIInteractionDataResolvedChannel,
|
||||
@@ -705,8 +704,7 @@ export interface ApplicationCommandInteractionOptionResolver<Cached extends Cach
|
||||
getNumber(name: string, required?: boolean): number | null;
|
||||
getUser(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['user']>;
|
||||
getUser(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['user']> | null;
|
||||
getMember(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['member']>;
|
||||
getMember(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['member']> | null;
|
||||
getMember(name: string): NonNullable<CommandInteractionOption<Cached>['member']> | null;
|
||||
getRole(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['role']>;
|
||||
getRole(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['role']> | null;
|
||||
getMentionable(
|
||||
@@ -781,8 +779,7 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
|
||||
public getNumber(name: string, required?: boolean): number | null;
|
||||
public getUser(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['user']>;
|
||||
public getUser(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['user']> | null;
|
||||
public getMember(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['member']>;
|
||||
public getMember(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['member']> | null;
|
||||
public getMember(name: string): NonNullable<CommandInteractionOption<Cached>['member']> | null;
|
||||
public getRole(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['role']>;
|
||||
public getRole(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['role']> | null;
|
||||
public getMentionable(
|
||||
|
||||
@@ -1073,7 +1073,6 @@ client.on('interactionCreate', async interaction => {
|
||||
expectAssignable<ChatInputCommandInteraction>(interaction);
|
||||
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||
expectType<APIInteractionDataResolvedGuildMember | null>(interaction.options.getMember('test'));
|
||||
expectType<APIInteractionDataResolvedGuildMember>(interaction.options.getMember('test', true));
|
||||
|
||||
expectType<APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
||||
expectType<APIRole>(interaction.options.getRole('test', true));
|
||||
@@ -1096,7 +1095,6 @@ client.on('interactionCreate', async interaction => {
|
||||
expectType<ChatInputCommandInteraction>(interaction);
|
||||
expectType<Promise<Message | APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||
expectType<APIInteractionDataResolvedGuildMember | GuildMember | null>(interaction.options.getMember('test'));
|
||||
expectType<APIInteractionDataResolvedGuildMember | GuildMember>(interaction.options.getMember('test', true));
|
||||
|
||||
expectType<GuildBasedChannel | APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
||||
expectType<APIRole | Role>(interaction.options.getRole('test', true));
|
||||
|
||||
Reference in New Issue
Block a user