i get the "This interaction failed" error for the last five "if" statements.

Dont know why its only those.
21 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
d.js docs
d.js docs4mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
AccountNoLongerInUse
did that, it doesnt run
interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
when i click any of the last 5
duck
duck4mo ago
yes, but where does execution stop? what does run?
AccountNoLongerInUse
right here. it runs everything before that, this just doesnt run this if any of the last five if statements are clicked
duck
duck4mo ago
the point isn't to find out what line is the first to not execute the condition for one of your if statements is false logging throughout, particularly before each if statement, will help you find out which one then you can log the appropriate values to understand why it's not as expected
AccountNoLongerInUse
i put console.log in all the if statements, all of them sent back what it was supposed too, i did it for the code before it, everything ran fine, i dont know why the ending statement doesnt run with the last five, it should do it fine, but it doesnt
duck
duck4mo ago
all of them sent back what it was supposed too
so if you log something right before this line, it does log?
AccountNoLongerInUse
if(interaction.values.includes('colossians')) {
console.log('COLOSSIANS passed')
if(colossiansID.includes(interaction.user.id)) {
target.send("You have been invited to The Colossians! To leave the team, run /leave").catch(error => {
console.log(error)
})
target.roles.add(colossiansRole)
return;
}
} else {
interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
console.log('Nuh uh passed')

return;
if(interaction.values.includes('colossians')) {
console.log('COLOSSIANS passed')
if(colossiansID.includes(interaction.user.id)) {
target.send("You have been invited to The Colossians! To leave the team, run /leave").catch(error => {
console.log(error)
})
target.roles.add(colossiansRole)
return;
}
} else {
interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
console.log('Nuh uh passed')

return;
yep
duck
duck4mo ago
as in Nuh uh passed logs?
AccountNoLongerInUse
no, it doesnt run that if i click one of the last five options, if i do it with the others, it runs fine
duck
duck4mo ago
that doesn't sound like "all of them sent back what it was supposed too" what is the last line to log?
AccountNoLongerInUse
console.log('COLOSSIANS passed') or whatever option i clicked (it doesnt run the second if statement inside it, i know, thats intentional, it worked for the past ones)
duck
duck4mo ago
well if COLOSSIANS passed logs, why would you expect that else to execute? the condition was true
AccountNoLongerInUse
because it did it for the other ones with the (almost) exact same code
duck
duck4mo ago
for the other if statements where the condition was false, yes
AccountNoLongerInUse
nope, it said it passed, then ran the interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
duck
duck4mo ago
so Nuh uh passed logs?
AccountNoLongerInUse
correct
duck
duck4mo ago
so I take it you're talking about two separate executions of all of this code in that case, I'm fully willing to believe that interaction.values.includes('colossians') is false if interaction.values contains different values which would make the else execute since that is how if/else statements work but you can't expect the else to execute if the if was true
AccountNoLongerInUse
im going to try putting else { interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
console.log('Nuh uh passed')
return; } in each if statement that seemed to work thanks
Want results from more Discord servers?
Add your server