Having trouble with discord bot from python tutorial

I have look back too many time and i cant find what wrong, and why can I not run the thing and it wont say we have logged in

because your client.run statement is inside other stuff instead of being global

your indentation is wrong, make sure it matches exactly as provided, or it is wrong and will not do what you want

I imagine you are following this tutorial

Check your code against the provided code

Sorry, im still confused on what you mean my client.run statement being global, do you mean by my project being private because i put it as private,

but i did fix my indentation.

Do you have the TOKEN in the Secret tab?

i blur a little of it so people cant see it but yes i did

got a new token just to make sure im safe

the name of the file should be .env, with the dot on front, not env.

But replit doesn’t allow the creation of an .env file anymore, so you need to use the Secret tab, you can access it on the left, it’s the one with the locket symbol

sorry if im asking too much, because im very new to this, but i created my secret code now
what do i do next

you probably can’t use getenv with the secret tab in replit, use the insert button provided in the secret tab for the correct statement

I’m confuse on how to do that

go to the secret tab, find the name of the secret you need to use, use the corresponding Insert button, it will add an assignment expression to a variable named my_secret. You can add the my_secret variable inside client.run or instead take the part to the right of the assignment operator and add that inside client.run, also make sure that if you use the variable, it is declared before it is used

is this how you do it?

didn’t you save it as TOKEN? it works anyway, it’s just a weird name

and no, or the variable my_secret, with the assignment on a previous line, or only the right part of the assignment

Also, remember that it is always easier to help you if you provide your code, or the link to your project (the secret tab is not accessible by others), screenshots are always hard to help with

1 Like

here ya go : D


client.run(os.environ['the forbidden code 0_0'])

If that is still your key value, that is.

I followed the video: Code a Discord Bot with Python - Host for Free in the Cloud - YouTube
But my script looks like:

follow the discussion in this thread, it’s exactly the same issue

I’ve looked over everything and I don’t see anything that helps me .

the last line should be client.run, and you need to use your secret name, not the one of the other user. then you can use my_secret as argument of client.run