ShorkKeith
DIAdiscord.js - Imagine a bot
•Created by ShorkKeith on 8/15/2024 in #djs-questions
Convoluted code giving InteractionAlreadyReplied error
Rather than asking for help with the code, I wanted help with the structure of it. My mango main goal is to blow up display a modal via reaction to allow the user to insert both the comment and rating. I was trying to first get it to work crudely as in put everything I'd need for that to work and then start refactoring and organizing it afterwards but I think I've stared at this long enough to fry my brain.
I've done this by setting up multiple collectors to listen for the reactions the user picks over and over.
The code
https://pastebin.com/bL3JpQLL
Error text
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ButtonInteraction.deferReply (xxx\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69)
at ReactionCollector.<anonymous> (xxx\src\commands\Primary\lookup.js:220:21)
at ReactionCollector.emit (node:events:531:35)
at ReactionCollector.handleCollect (xxx\node_modules\discord.js\src\structures\interfaces\Collector.js:133:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionAlreadyReplied'
}
Open to reconsiderations
Would generating a modal be the best approach, even? Should I just try via button or even give the comment feature as a separated command? It would be redundant since this command is used to search for professors already so why not having the option of commenting on them once found.
Any feedback, roast and meme about it is appreciated. Error is generated at line 220.
7 replies