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.
Pastebin
lookup.js - Pastebin.com
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.
6 Replies
d.js toolkit
d.js toolkit5mo ago
- 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 OP
d.js docs
d.js docs5mo ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
xx_lavaboy_xx123
but without even looking at the code i can tell u that u can't show a modal when someone uses a reaction because modals can only be displayed as a reply to interactions
ShorkKeith
ShorkKeithOP5mo ago
damn, that's a shame
TÆMBØ
TÆMBØ5mo ago
And then act like I don't know nobody? /ij I'm not sure modals would fit into this unless you use them as the response to a user pressing one of the buttons. Interactions can only be acknowledged once, and showModal() is a way of acknowledging, so you can't reply() to your commandInteraction and then later also showModal() with it as well. You should really be replacing your interactions with a separate row of buttons instead. With those, you can then show modals to them. As a side note, ModalSubmitInteractions are collected in-scope via <Interaction>.awaitModalSubmit(), and not via createMessageComponentCollector() since modals aren't message components
ShorkKeith
ShorkKeithOP5mo ago
Har Har Har Har! Noted, I think I am going to do the button route instead. If you have any suggestions about how could I structure it better, I'm all ears
Want results from more Discord servers?
Add your server