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 toolkit14mo 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
alesi14mo ago
Syjalo
Syjalo14mo ago
Don't create listeners in commands. Use collectors.
d.js docs
d.js docs14mo 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
alesi14mo ago
So should I change my client.on(interactionCreate..... for a collector?
Syjalo
Syjalo14mo ago
Yes
alesi
alesi14mo 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
alesi14mo ago
i changed to this
alesi
alesi14mo ago
returned interaction failed when clicked button
Syjalo
Syjalo14mo ago
I suppose your message is the command message from user that doesn't have the buttons. You need to use mensaje
alesi
alesi14mo ago
that worked, thanks so much sir i was over 2 hours trying to find out whats was going wrong