awaitMessageComponent 'Interaction has already been acknowledged' Error

I have the following piece of code alongside multiple buttons. The idea is that you can - manipulate the embed with various buttons - ... until you either confirm the selection or reject it. - You should be able to press any button as many times as you want, up until you confirm or reject. If there's a different approach overall, I'd simply like the timer to reset everytime a button is pressed, acting more like an inactivity check. I am hesitant to use a while loop, since this seems like an obvious infinite loop. A recursive function could cause some memory issues. What is a sensible approach to this task? Is there a way to "await" a messageComponentCollector's response (either from "collect" or "end")?
11 Replies
d.js docs
d.js docs3y ago
method Message#awaitMessageComponent() Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
MrMythical
MrMythical3y ago
This what you want?
Luca | LeCarbonator
wow, that is exactly what I wanted. Thanks for the quick response @Myth 🌈
MrMythical
MrMythical3y ago
👍
Luca | LeCarbonator
Currently receiving the following error. I'm not sure what exactly went wrong here ...
Luca | LeCarbonator
DiscordAPIError[40060]: Interaction has already been acknowledged.
at SequentialHandler.runRequest (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:659:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:458:14)
at async REST.request (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:902:22)
at async ButtonInteraction.update (C:\<<FILEPATH>>\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:226:5)
requestBody: { files: [], json: { type: 7, data: [Object] } },
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST'
DiscordAPIError[40060]: Interaction has already been acknowledged.
at SequentialHandler.runRequest (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:659:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:458:14)
at async REST.request (C:\<<FILEPATH>>\node_modules\@discordjs\rest\dist\index.js:902:22)
at async ButtonInteraction.update (C:\<<FILEPATH>>\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:226:5)
requestBody: { files: [], json: { type: 7, data: [Object] } },
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST'
seems to specifically be an error with deferUpdate(). Removing that line from filter and changing editreply to update fixes it. But how do you use deferUpdate() then? This piece of code is nearly identical to the guide example.
monbrey
monbrey3y ago
Yeah thats not a great example, since the deferUpdate there isnt awaited
Luca | LeCarbonator
should I create a github issue for it?
monbrey
monbrey3y ago
Nah those sections are being rewritten anyway
Luca | LeCarbonator
alright bueno just wanted to make sure I'm not missing an obvious mistake on my end
Want results from more Discord servers?
Add your server