mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
types(TextBasedChannels): fix awaitMessageComponent return type (#6723)
This commit is contained in:
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -2817,7 +2817,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
||||
readonly lastPinAt: Date | null;
|
||||
awaitMessageComponent<T extends MessageComponentType | MessageComponentTypes | undefined = undefined>(
|
||||
options?: AwaitMessageCollectorOptionsParams<T>,
|
||||
): Promise<InteractionCollectorReturnType<T>>;
|
||||
): Promise<InteractionExtractor<T>>;
|
||||
awaitMessages(options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
||||
bulkDelete(
|
||||
messages: Collection<Snowflake, Message> | readonly MessageResolvable[] | number,
|
||||
|
||||
@@ -498,21 +498,26 @@ client.on('messageCreate', message => {
|
||||
// Verify that buttons interactions are inferred.
|
||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
||||
assertType<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'BUTTON' }));
|
||||
assertType<Promise<ButtonInteraction>>(channel.awaitMessageComponent({ componentType: 'BUTTON' }));
|
||||
assertType<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
||||
|
||||
// Verify that select menus interaction are inferred.
|
||||
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' });
|
||||
assertType<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
||||
assertType<Promise<SelectMenuInteraction>>(channel.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
||||
assertType<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
||||
|
||||
// Verify that message component interactions are default collected types.
|
||||
const defaultCollector = message.createMessageComponentCollector();
|
||||
assertType<Promise<MessageComponentInteraction>>(message.awaitMessageComponent());
|
||||
assertType<Promise<MessageComponentInteraction>>(channel.awaitMessageComponent());
|
||||
assertType<InteractionCollector<MessageComponentInteraction>>(defaultCollector);
|
||||
|
||||
// Verify that additional options don't affect default collector types.
|
||||
const semiDefaultCollector = message.createMessageComponentCollector({ time: 10000 });
|
||||
assertType<InteractionCollector<MessageComponentInteraction>>(semiDefaultCollector);
|
||||
const semiDefaultCollectorChannel = message.createMessageComponentCollector({ time: 10000 });
|
||||
assertType<InteractionCollector<MessageComponentInteraction>>(semiDefaultCollectorChannel);
|
||||
|
||||
// Verify that interaction collector options can't be used.
|
||||
|
||||
@@ -565,6 +570,29 @@ client.on('messageCreate', message => {
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
channel.awaitMessageComponent({
|
||||
filter: i => {
|
||||
assertType<MessageComponentInteraction>(i);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
channel.awaitMessageComponent({
|
||||
componentType: 'BUTTON',
|
||||
filter: i => {
|
||||
assertType<ButtonInteraction>(i);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
channel.awaitMessageComponent({
|
||||
componentType: 'SELECT_MENU',
|
||||
filter: i => {
|
||||
assertType<SelectMenuInteraction>(i);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
client.on('interaction', async interaction => {
|
||||
|
||||
Reference in New Issue
Block a user