MessageComponentCollector gives wrong button customId
Code: https://pastebin.com/Vk2fFSvi
Hi! So, I'm creating a tic-tac-toe command, and for the most part, it's done. However, I have a weird issue. I originally used an interactionCreate event with the buttons, but now I am changing it to a collector with a collect event. The issue is the fact that the collector doesn't get the right customId for the button. It works perfectly on the interactionCreate, but now it won't work with the collector. Yes, that is the only thing I changed. I did not touch anything else at all. And before you say that I should stick with the interactionCreate event, I can't because I need to handle each game on its own, which is what the collector will do, as it's specific to a message. Does anybody know why the collector is doing this and/or how to fix it?
It was suggested to post here, as my question/problem is a little more complicated than other ones, so here I am.
Pastebin
const Discord = require('discord.js');const { MessageActionRow, Mes...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
20 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPAlready have it in the tag, but version is 13.16.0
Should also note this:
I have my buttons defined with their custom IDs, and then I have the beginning of the collector. When pressing any of the buttons on row 3, it thinks button 5 with the
customId
ttt_button_5
was pressed, even though that's obviously not the correct button. In the console.log
line where I log the customId
of the button pressed, it does indeed output ttt_button_5
.
For new people, make sure to scroll up ^^If you press button 9 as the first interaction does it also log button 5?
lemme see
yes, it does
Where you create the collector can you also log tttMsg.components
you mean underneath
console.log(interaction.customId)
?
or outside of itAbove const collector
k
I'm guessing you wanted me to check what the buttons'
customId
s come out to be when logged, so I changed it to tttMsg.components[2]
to show the third row, which is where the issue persists.
Here's the full output of that log:
as you can see, the customId
s are correctOk. And if you move the log into the collect event?
outputs the same thing
Do you have any remnants of handling these buttons in the interactionCreate handler?
could you be a bit more specific?
You said you had them being handled in the interactionCreate event at some point. Is everything dealing with these buttons removed from that handler?
The code that was inside that is the exact same. I just switched the handlers themselves
hopefully that answers your question
So you don’t have an interactionCreate event at all since changing this to collectors. If I read that correctly.
That is correct
What's that for?
You’re assigning interaction.customId
ohhhhh
geez
ty!