Bot crashes during second /command use
My clear-table command works perfectly the first time you use /clear-table, but the second time, it crashes when you click the Clear Table button. I am new to discordjs and this is my first time using components and collectors.
https://gist.github.com/SowerofSystems/3f482470630ae1f90bcb526fecd6f3ff
5 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 OPTo share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.
Common causes of
DiscordAPIError[10062]: Unknown interaction
:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responsesSorry, I'm new to the server. I've added a Gist link as suggested by the bot
I assume I must be misunderstanding something about editing deferred replies?
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.
Thank you. I changed the channel to message in confirmClear(), and while I still got errors when I used the command in quick succession, it was working more consistently. I got this error:
I stored my message in a const on creation and created the collector on that instead.
After making that change it's working perfectly now. I've also added a try/catch to handle any erroneous bugs so it doesn't crash the bot.
I still don't entirely understand the issue, though. Is there any chance you could help me understand?