mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
fix: await message component collectors should return component interactions not collectors (#6562)
This commit is contained in:
10
typings/index.d.ts
vendored
10
typings/index.d.ts
vendored
@@ -1135,6 +1135,14 @@ type InteractionCollectorReturnType<T extends MessageComponentType | MessageComp
|
|||||||
? ConditionalInteractionCollectorType<MappedInteractionCollectorOptions[T]>
|
? ConditionalInteractionCollectorType<MappedInteractionCollectorOptions[T]>
|
||||||
: InteractionCollector<MessageComponentInteraction>;
|
: InteractionCollector<MessageComponentInteraction>;
|
||||||
|
|
||||||
|
type InteractionReturnType<T extends MessageComponentType | MessageComponentTypes | undefined> = T extends
|
||||||
|
| MessageComponentType
|
||||||
|
| MessageComponentTypes
|
||||||
|
? MappedInteractionCollectorOptions[T] extends InteractionCollectorOptions<infer Item>
|
||||||
|
? Item
|
||||||
|
: never
|
||||||
|
: MessageComponentInteraction;
|
||||||
|
|
||||||
type MessageCollectorOptionsParams<T> =
|
type MessageCollectorOptionsParams<T> =
|
||||||
| ({ componentType?: T } & InteractionCollectorOptionsResolvable)
|
| ({ componentType?: T } & InteractionCollectorOptionsResolvable)
|
||||||
| InteractionCollectorOptions<MessageComponentInteraction>;
|
| InteractionCollectorOptions<MessageComponentInteraction>;
|
||||||
@@ -1192,7 +1200,7 @@ export class Message extends Base {
|
|||||||
public reference: MessageReference | null;
|
public reference: MessageReference | null;
|
||||||
public awaitMessageComponent<T extends MessageComponentType | MessageComponentTypes | undefined = undefined>(
|
public awaitMessageComponent<T extends MessageComponentType | MessageComponentTypes | undefined = undefined>(
|
||||||
options?: AwaitMessageCollectorOptionsParams<T>,
|
options?: AwaitMessageCollectorOptionsParams<T>,
|
||||||
): Promise<InteractionCollectorReturnType<T>>;
|
): Promise<InteractionReturnType<T>>;
|
||||||
public awaitReactions(options?: AwaitReactionsOptions): Promise<Collection<Snowflake | string, MessageReaction>>;
|
public awaitReactions(options?: AwaitReactionsOptions): Promise<Collection<Snowflake | string, MessageReaction>>;
|
||||||
public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
|
public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
|
||||||
public createMessageComponentCollector<
|
public createMessageComponentCollector<
|
||||||
|
|||||||
@@ -494,21 +494,17 @@ client.on('messageCreate', message => {
|
|||||||
|
|
||||||
// Verify that buttons interactions are inferred.
|
// Verify that buttons interactions are inferred.
|
||||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
||||||
assertType<Promise<InteractionCollector<ButtonInteraction>>>(
|
assertType<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'BUTTON' }));
|
||||||
message.awaitMessageComponent({ componentType: 'BUTTON' }),
|
|
||||||
);
|
|
||||||
assertType<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
assertType<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
||||||
|
|
||||||
// Verify that select menus interaction are inferred.
|
// Verify that select menus interaction are inferred.
|
||||||
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' });
|
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' });
|
||||||
assertType<Promise<InteractionCollector<SelectMenuInteraction>>>(
|
assertType<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
||||||
message.awaitMessageComponent({ componentType: 'SELECT_MENU' }),
|
|
||||||
);
|
|
||||||
assertType<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
assertType<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
||||||
|
|
||||||
// Verify that message component interactions are default collected types.
|
// Verify that message component interactions are default collected types.
|
||||||
const defaultCollector = message.createMessageComponentCollector();
|
const defaultCollector = message.createMessageComponentCollector();
|
||||||
assertType<Promise<InteractionCollector<MessageComponentInteraction>>>(message.awaitMessageComponent());
|
assertType<Promise<MessageComponentInteraction>>(message.awaitMessageComponent());
|
||||||
assertType<InteractionCollector<MessageComponentInteraction>>(defaultCollector);
|
assertType<InteractionCollector<MessageComponentInteraction>>(defaultCollector);
|
||||||
|
|
||||||
// Verify that additional options don't affect default collector types.
|
// Verify that additional options don't affect default collector types.
|
||||||
|
|||||||
Reference in New Issue
Block a user