Button Automatically Pressing

Hello! Im currently working on a bot using oauth2. Im in the middle of rewriting how i handle refreshing access tokens if they are invalid but ive stumbled on an issue. As you can see in the video attached i run my /dashboard command and then click Verify Tokens button that works fine but once the verification is complete (i have an invalid access token in my database on purpose for debuging) im given the option if i want to try refreshing the invalid tokens both button should currently just respond with a placeholder text but for some reason when the message is sent the Yes button pushes it self and says interaction failed. Here is the code for the command: https://pastecode.io/s/om3zdqnv (Some functions are not being used as like i said im in the middle of rewriting it) Huge thanks to anyone who even takes a look at this
13 Replies
d.js toolkit
d.js toolkit4mo 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
Chloe
Chloe4mo ago
mp4 video*
sludge
sludge4mo ago
I think its a visual issue with the client owing to you editing the reply but not actually responding to the button interaction reply.edit on line 229 should really be interaction.update
d.js docs
d.js docs4mo ago
:method: ButtonInteraction#update() Updates the original message of the component on which the interaction was received on.
Syjalo
Syjalo4mo ago
Not only in line 229. Everywhere where the interaction should be acknowledged
sludge
sludge4mo ago
yeah, sorry I zero'd in on the reason it was happening in the video but yeah all instances of reply.edit should be fixed
Chloe
Chloe4mo ago
Replaced it everywhere though now i get an error about it
interaction.update({ embeds: [embed], components: [row] });
^

TypeError: interaction.update is not a function
at handleValidation (D:\Projekty\dis bot\pull-bot\commands\utility\dashboard
.js:202:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)

Node.js v20.12.2
interaction.update({ embeds: [embed], components: [row] });
^

TypeError: interaction.update is not a function
at handleValidation (D:\Projekty\dis bot\pull-bot\commands\utility\dashboard
.js:202:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)

Node.js v20.12.2
Syjalo
Syjalo4mo ago
In the scope of handleValidation function interaction is your slash command interaction. Pass the button interaction to the function
Chloe
Chloe4mo ago
by that you mean change reply to interaction here?
No description
Chloe
Chloe4mo ago
wait huh i kinda get it but how do i pass the button interaction?
Syjalo
Syjalo4mo ago
The only interaction for your handleValidation function is from execute parameter which is the slash command interaction. You need to pass the button interaction from the collector to your function arguments
No description
No description
Chloe
Chloe4mo ago
So if i understand do this?
No description
No description
Chloe
Chloe4mo ago
so i did that and new error progress!
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.update (D:\Projekty\dis bot\pull-bot\node_modules\discord.js\src\structures\interfaces\Inter
actionResponses.js:225:46)
at handleValidation (D:\Projekty\dis bot\pull-bot\commands\utility\dashboard.js:202:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionAlreadyReplied'
}

Node.js v20.12.2
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.update (D:\Projekty\dis bot\pull-bot\node_modules\discord.js\src\structures\interfaces\Inter
actionResponses.js:225:46)
at handleValidation (D:\Projekty\dis bot\pull-bot\commands\utility\dashboard.js:202:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'InteractionAlreadyReplied'
}

Node.js v20.12.2
talks about line 202
interaction.update({ embeds: [embed], components: [row] });
interaction.update({ embeds: [embed], components: [row] });
i changed line 202 to
reply.edit({ embeds: [embed], components: [row] });
reply.edit({ embeds: [embed], components: [row] });
and it works as it should now is there anything i should worry about with this aproach or should i just let it be?