discord.js
discord.js copied to clipboard
InteractionResponse#awaitMessageComponent
Which package is this bug report for?
discord.js
Issue description
The awaitMessageComponent method doesn't work when called on an InteractionResponse despite it existing and being typed as valid. The method will never catch an interaction and will reject if a time period is specified. Not sure why this happens seeing as the InteractionCollector class accepts an interactionResponse in its constructor.
Code sample
if (interaction.isButton()) {
const res = await interaction.update({ content: new Date().toISOString(), components: interaction.message.components }),
int = await res.awaitMessageComponent({ time: 5_000 }).catch(() => null)
console.log(int) // int will always be null, even if you reply before the 5 second limit
}
Package version
14.2.0
Node.js version
18.7.0
Operating system
Windows 11
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
Not applicable (subpackage bug)
Which gateway intents are you subscribing to?
Not applicable (subpackage bug)
I have tested this issue on a development release
No response
Is your original message is an ephemeral message? If so, ig it's a duplicate of https://github.com/discordjs/discord.js/issues/7992
Happened with both an ephemeral and a non ephemeral message
Although I had this problem when using the InteractionResponse
from a ModalSubmitInteraction
I could not repro this issue anymore, this issue even persist when creating a raw InteractionCollector
and passing the interaction responseas argument. Extensive tests made using Yuudachi's code (Example https://github.com/Naval-Base/yuudachi/blob/main/packages/yuudachi/src/commands/moderation/warn.ts#L71) and all the other files did not show any problems. I will test the provided code and update this comment accordingly
@JPBM135 so you fixed the issue or you didn't? If you fixed it, how did you fix it?
This issue is caused when calling awaitMessageComponent
on a MessageComponentInteraction
when the MessageComponent
was sent in a message not replying to an interaction.
The MessageComponentInteraction
's ID is stored here: https://github.com/discordjs/discord.js/blob/4ffdada4f7a9f8d5bc242353e03c73d5604163a5/packages/discord.js/src/structures/InteractionResponse.js#L20
Here, the stored ID is compared with the ID of the message's CommandInteraction
: https://github.com/discordjs/discord.js/blob/4ffdada4f7a9f8d5bc242353e03c73d5604163a5/packages/discord.js/src/structures/InteractionCollector.js#L153
Me too. Same phenomenon when call awaitMessageComponent on Message type. Node.js Ver:19.0.1 Discord.js: 14.7.1