How to avoid interaction listener mixing commands

Im coding a command which update a user from a database, it returns an embed message with user's information and it have a row with buttons to select properties to change. The problem is that when i make another instance of the command every embed used previously also change with the new responses.
11 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
alesi
alesiOP2y ago
Syjalo
Syjalo2y ago
Don't create listeners in commands. Use collectors.
d.js docs
d.js docs2y ago
If you are waiting for button or select menu input from a specific message, don't create the collector on the channel. • Channel collectors return component interactions for any component within that channel.
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
alesi
alesiOP2y ago
So should I change my client.on(interactionCreate..... for a collector?
Syjalo
Syjalo2y ago
Yes
alesi
alesiOP2y ago
Ok i will try it I dont find out how should I make the change to collector, changed the listener for the collector with same code inside but now i receive interaction failed when clicking buttons, any idea ? @syjalo
alesi
alesiOP2y ago
i changed to this
alesi
alesiOP2y ago
returned interaction failed when clicked button
Syjalo
Syjalo2y ago
I suppose your message is the command message from user that doesn't have the buttons. You need to use mensaje
alesi
alesiOP2y ago
that worked, thanks so much sir i was over 2 hours trying to find out whats was going wrong
Want results from more Discord servers?
Add your server