Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InteractionResponse#awaitMessageComponent #8501

Closed
ImRodry opened this issue Aug 16, 2022 · 6 comments · Fixed by #8598
Closed

InteractionResponse#awaitMessageComponent #8501

ImRodry opened this issue Aug 16, 2022 · 6 comments · Fixed by #8598

Comments

@ImRodry
Copy link
Contributor

ImRodry commented Aug 16, 2022

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

@imranbarbhuiya
Copy link
Contributor

Is your original message is an ephemeral message? If so, ig it's a duplicate of #7992

@ImRodry
Copy link
Contributor Author

ImRodry commented Aug 16, 2022

Happened with both an ephemeral and a non ephemeral message

@JPBM135
Copy link
Contributor

JPBM135 commented Aug 23, 2022

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

@ImRodry
Copy link
Contributor Author

ImRodry commented Aug 23, 2022

@JPBM135 so you fixed the issue or you didn't? If you fixed it, how did you fix it?

@cobaltt7
Copy link
Contributor

cobaltt7 commented Sep 5, 2022

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:

Here, the stored ID is compared with the ID of the message's CommandInteraction:

if (this.messageInteractionId && interaction.message?.interaction?.id !== this.messageInteractionId) return null;

@Kayxue
Copy link

Kayxue commented Dec 11, 2022

Me too.
Same phenomenon when call awaitMessageComponent on Message type.
Node.js Ver:19.0.1
Discord.js: 14.7.1

@kodiakhq kodiakhq bot closed this as completed in #8598 Jun 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants