#Code doesn't `return` (I still need help)

91 messages · Page 1 of 1 (latest)

hybrid tinselBOT
#
  • 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
graceful trail
#

Please ping me when you answer

bright violet
#

im confused. theres no return in the code block which you claim logs continued

#

So why do you think it would be returning?

graceful trail
#

The function has it
That won't work?

bright violet
#

return exits the function

#

its working

#

It doesnt return from anything but that function

#

It returns back to where the function was executed

graceful trail
#

oh
How can I return from the main file as well?
I tried it but this happened

I tried using if (notEnoughPermissions){return} but it returns everytime that way, even if it has the permissions.

bright violet
#

notEnoughPermissions needs to return a boolean to that if

#

Otherwise how is it supposed to know?

#

You arent calling the function though

#

The function takes 5 parameters

graceful trail
#

these?

bright violet
#

I think you might need to learn a bit more Javascript

graceful trail
#

I have them

bright violet
#

Well, that function is notEnoughChannelPermissionsEmbed which would be different to notEnoughPermissions

graceful trail
#

But I do const

bright violet
#

But for it to work, you need to pass those 5 things to the function when you call it

#

you... what

graceful trail
#

why do i need to call it like that again?

bright violet
#

oh, I missed code in your screenshot

graceful trail
#

This doesn't work?

graceful trail
bright violet
#

well, yes

#

Your code does not attempt to return

graceful trail
#

So in order to make it recieve a boolean
I need to add something inside the function?

bright violet
#

It just console.logs true

#

Then continues

graceful trail
#

it returns even if it has permissions

#

That if gets always triggered that way

#

idk why

bright violet
#

Then your function is wrong

#

And it always returning true

graceful trail
#

idk how to make it return false in this case

#

because thats the whole copde i sent you

bright violet
#

yes

graceful trail
#

there is nothing else

bright violet
#

but that wont fix anything if its already returning true all the time

graceful trail
#

omg it still continues 😭

graceful trail
#

Which one is easier to read?

bright violet
#

code

#

but theres not much else I can see

#

Its always returning true

graceful trail
#

It always logs enough permissions and continued even if it doesn't have those permissions

graceful trail
bright violet
#

yes

#

well.... you now have a double negative?

#

notEnoughPermissions returns true....

#

Then you do if(!notEnoughPermissions)

#

not-notEnoughPermissions

graceful trail
#

But does it matter?
let me fixc ok one sec

bright violet
#

Yes, thats why I'm pointing it out meguFace

#

Having incorrect logic in your if matters a lot

graceful trail
#
    await notEnoughPermissions;
    if (notEnoughPermissions) {
      console.log("enough permissions");
    } else {
      console.log("not enough permissions");
      return;
    }```
#

Still logging enough permissions even if it has not

#

I don't get it 😦

#

I wasted 3 hours on this

#

I can't understand the logic behind this

spark lynx
#

I dont think not enoughpermissions returns a promise so why await it. I think you need to brush up on your js skills. 👍

graceful trail
#

There is no await normally

spark lynx
#

If you knew it didn’t return a promise why “try” it? Doesn’t change anything in your code

graceful trail
#

Please don't argue about this if you are not going to help
I'm already exhausted

spark lynx
#

I’m not arguing. Stating what your code says

graceful trail
#

Please stop and leave the post so the mods can see the code message
Otherwise it won't be visible (the more you write the more it goes to the top)

spark lynx
#

Heres what i think. You have a promising thing here just don’t completely grasp the logic for some of it. Please learn some more js. But when someone helps you and points something out, getting offensive helps nothing

graceful trail
spark lynx
#

notEnoughPermissions is supposed to be what?

graceful trail
#

Code doesn't return (I still need help)

graceful trail
spark lynx
#

I’m not making fun of your skills. I literally said it was promising code. Have you logged what notEnoughPermissions is?

graceful trail
#

Look, I am thankful for you trying to help me, but please stop writing here. I kindly want you to ignore my post.

spark lynx
#

In order for an if statement to work, what’s inside have to return true or false.

graceful trail
#

I don't want to explain to you what this code does since it is clear

graceful trail
spark lynx
#

Well it needs the condition to return true or false

#

For the if to work

graceful trail
#

You are just telling stuff that we already know though

#

We know that, the issue is that I don't know why this one doesn't

#

Please stop writing here so I don't have to send the code multiple times here, other wise mods might think this issue has been solved

spark lynx
#

Well ok. Have a nice day. Gl