i get the "This interaction failed" error for the last five "if" statements.
Dont know why its only those.
21 Replies
- 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 OPIf 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 moredid that, it doesnt run when i click any of the last 5
yes, but where does execution stop?
what does run?
right here. it runs everything before that, this just doesnt run this if any of the last five if statements are clicked
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
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
all of them sent back what it was supposed tooso if you log something right before this line, it does log?
yep
as in
Nuh uh passed
logs?no, it doesnt run that if i click one of the last five options, if i do it with the others, it runs fine
that doesn't sound like "all of them sent back what it was supposed too"
what is the last line to log?
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)
well if
COLOSSIANS passed
logs, why would you expect that else
to execute?
the condition was truebecause it did it for the other ones
with the (almost) exact same code
for the other if statements where the condition was false, yes
nope, it said it passed, then ran the interaction.update({content: '... Really thought that would work??? You are not that Team Captain', ephemeral: true})
so
Nuh uh passed
logs?correct
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 trueim 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
console.log('Nuh uh passed')
return; } in each if statement that seemed to work thanks