mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
types(MessageComponentInteraction): Ensure component is not null (#7099)
This commit is contained in:
20
typings/index.d.ts
vendored
20
typings/index.d.ts
vendored
@@ -448,6 +448,13 @@ export class BitField<S extends string, N extends number | bigint = number> {
|
|||||||
|
|
||||||
export class ButtonInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
|
export class ButtonInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
|
||||||
private constructor(client: Client, data: RawMessageButtonInteractionData);
|
private constructor(client: Client, data: RawMessageButtonInteractionData);
|
||||||
|
public readonly component: CacheTypeReducer<
|
||||||
|
Cached,
|
||||||
|
MessageButton,
|
||||||
|
APIButtonComponent,
|
||||||
|
MessageButton | APIButtonComponent,
|
||||||
|
MessageButton | APIButtonComponent
|
||||||
|
>;
|
||||||
public componentType: 'BUTTON';
|
public componentType: 'BUTTON';
|
||||||
public inGuild(): this is ButtonInteraction<'present'>;
|
public inGuild(): this is ButtonInteraction<'present'>;
|
||||||
public inCachedGuild(): this is ButtonInteraction<'cached'>;
|
public inCachedGuild(): this is ButtonInteraction<'cached'>;
|
||||||
@@ -1535,8 +1542,10 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
public readonly component: CacheTypeReducer<
|
public readonly component: CacheTypeReducer<
|
||||||
Cached,
|
Cached,
|
||||||
MessageActionRowComponent,
|
MessageActionRowComponent,
|
||||||
Exclude<APIMessageComponent, APIActionRowComponent>
|
Exclude<APIMessageComponent, APIActionRowComponent>,
|
||||||
> | null;
|
MessageActionRowComponent | Exclude<APIMessageComponent, APIActionRowComponent>,
|
||||||
|
MessageActionRowComponent | Exclude<APIMessageComponent, APIActionRowComponent>
|
||||||
|
>;
|
||||||
public componentType: Exclude<MessageComponentType, 'ACTION_ROW'>;
|
public componentType: Exclude<MessageComponentType, 'ACTION_ROW'>;
|
||||||
public customId: string;
|
public customId: string;
|
||||||
public channelId: Snowflake;
|
public channelId: Snowflake;
|
||||||
@@ -1871,6 +1880,13 @@ export class Role extends Base {
|
|||||||
|
|
||||||
export class SelectMenuInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
|
export class SelectMenuInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
|
||||||
public constructor(client: Client, data: RawMessageSelectMenuInteractionData);
|
public constructor(client: Client, data: RawMessageSelectMenuInteractionData);
|
||||||
|
public readonly component: CacheTypeReducer<
|
||||||
|
Cached,
|
||||||
|
MessageSelectMenu,
|
||||||
|
APISelectMenuComponent,
|
||||||
|
MessageSelectMenu | APISelectMenuComponent,
|
||||||
|
MessageSelectMenu | APISelectMenuComponent
|
||||||
|
>;
|
||||||
public componentType: 'SELECT_MENU';
|
public componentType: 'SELECT_MENU';
|
||||||
public values: string[];
|
public values: string[];
|
||||||
public inGuild(): this is SelectMenuInteraction<'present'>;
|
public inGuild(): this is SelectMenuInteraction<'present'>;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import type {
|
|||||||
APIInteractionDataResolvedGuildMember,
|
APIInteractionDataResolvedGuildMember,
|
||||||
APIInteractionDataResolvedChannel,
|
APIInteractionDataResolvedChannel,
|
||||||
APIRole,
|
APIRole,
|
||||||
|
APIButtonComponent,
|
||||||
|
APISelectMenuComponent,
|
||||||
} from 'discord-api-types/v9';
|
} from 'discord-api-types/v9';
|
||||||
import { AuditLogEvent } from 'discord-api-types/v9';
|
import { AuditLogEvent } from 'discord-api-types/v9';
|
||||||
import {
|
import {
|
||||||
@@ -85,6 +87,8 @@ import {
|
|||||||
StageInstance,
|
StageInstance,
|
||||||
Sticker,
|
Sticker,
|
||||||
Emoji,
|
Emoji,
|
||||||
|
MessageActionRowComponent,
|
||||||
|
MessageSelectMenu,
|
||||||
} from '.';
|
} from '.';
|
||||||
import type { ApplicationCommandOptionTypes } from './enums';
|
import type { ApplicationCommandOptionTypes } from './enums';
|
||||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||||
@@ -955,16 +959,20 @@ client.on('interactionCreate', async interaction => {
|
|||||||
|
|
||||||
if (interaction.isButton()) {
|
if (interaction.isButton()) {
|
||||||
expectType<ButtonInteraction>(interaction);
|
expectType<ButtonInteraction>(interaction);
|
||||||
|
expectType<MessageButton | APIButtonComponent>(interaction.component);
|
||||||
if (interaction.inCachedGuild()) {
|
if (interaction.inCachedGuild()) {
|
||||||
expectAssignable<ButtonInteraction>(interaction);
|
expectAssignable<ButtonInteraction>(interaction);
|
||||||
|
expectType<MessageButton>(interaction.component);
|
||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectAssignable<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
expectAssignable<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<ButtonInteraction>(interaction);
|
expectAssignable<ButtonInteraction>(interaction);
|
||||||
|
expectType<APIButtonComponent>(interaction.component);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<ButtonInteraction>(interaction);
|
expectAssignable<ButtonInteraction>(interaction);
|
||||||
|
expectType<MessageButton | APIButtonComponent>(interaction.component);
|
||||||
expectAssignable<Guild | null>(interaction.guild);
|
expectAssignable<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<APIMessage | Message>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<APIMessage | Message>>(interaction.reply({ fetchReply: true }));
|
||||||
}
|
}
|
||||||
@@ -972,16 +980,20 @@ client.on('interactionCreate', async interaction => {
|
|||||||
|
|
||||||
if (interaction.isMessageComponent()) {
|
if (interaction.isMessageComponent()) {
|
||||||
expectType<MessageComponentInteraction>(interaction);
|
expectType<MessageComponentInteraction>(interaction);
|
||||||
|
expectType<MessageActionRowComponent | APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
||||||
if (interaction.inCachedGuild()) {
|
if (interaction.inCachedGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
|
expectType<MessageActionRowComponent>(interaction.component);
|
||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectAssignable<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
expectAssignable<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
|
expectType<APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
|
expectType<MessageActionRowComponent | APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<APIMessage | Message>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<APIMessage | Message>>(interaction.reply({ fetchReply: true }));
|
||||||
}
|
}
|
||||||
@@ -989,16 +1001,20 @@ client.on('interactionCreate', async interaction => {
|
|||||||
|
|
||||||
if (interaction.isSelectMenu()) {
|
if (interaction.isSelectMenu()) {
|
||||||
expectType<SelectMenuInteraction>(interaction);
|
expectType<SelectMenuInteraction>(interaction);
|
||||||
|
expectType<MessageSelectMenu | APISelectMenuComponent>(interaction.component);
|
||||||
if (interaction.inCachedGuild()) {
|
if (interaction.inCachedGuild()) {
|
||||||
expectAssignable<SelectMenuInteraction>(interaction);
|
expectAssignable<SelectMenuInteraction>(interaction);
|
||||||
|
expectType<MessageSelectMenu>(interaction.component);
|
||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<SelectMenuInteraction>(interaction);
|
expectAssignable<SelectMenuInteraction>(interaction);
|
||||||
|
expectType<APISelectMenuComponent>(interaction.component);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<SelectMenuInteraction>(interaction);
|
expectAssignable<SelectMenuInteraction>(interaction);
|
||||||
|
expectType<MessageSelectMenu | APISelectMenuComponent>(interaction.component);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message | APIMessage>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message | APIMessage>>(interaction.reply({ fetchReply: true }));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user