Skip to content
← Back to Community
Nothing happens when i click "run" help
Profile icon
JustMatthew

I am fairly new to python programming. so i tried to make a discord bot and followed this tutorial by freecodecamp:https://youtu.be/SPTfmiYiuok. i dont know what i did wrong, everytime i click the run button nothing happens. any help would be greatly appreciated

Voters
Profile icon
JustMatthew
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

Solution

your error is because you are trying to access token. But you don't have an .env file. Try doing that, and then access it.

other than that, everything seems to be solved.

it should work

Profile icon
BD103

What @RYANTADIPARTHI means is that you should create a .env file and type the following format:

ENVNAME=DATA ANOTHERVAR=MOREDATA

Thankfully, .env files are hidden in replit, so owners/invited people can see them but others cannot. You can use this to store passwords, tokens, and more data you wish to keep private.

(Sorry RYANTADIPARTHI for going off of your answer, but it was kind of cryptic and hard to understand.)

Profile icon
RYANTADIPARTHI

@BD103 yeah no problem. You explained it in detail.

Profile icon
BD103

I'm glad you understand :D @RYANTADIPARTHI

Profile icon
RYANTADIPARTHI

@BD103 np :)

Profile icon
KHZ

@JustMatthew You messed up a little too much on the increments. Just copy the code below and paste it instead of your code from line 6:

@client.event async def on_ready(): print ('we have logged in as{0.user}'.format(client)) @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('?servant'): await message.channel.send('hello! i am the servant.') client.run(os.getenv('TOKEN'))

Your last line statement is also wrong. It should be client.run(os.getenv('TOKEN')) instead of client.run(os.gentev('TOKEN')). You misspelled the method getenv.

Profile icon
JustMatthew

@KHZ thank you so much, this helped alot

Profile icon
KHZ
Profile icon
CodingCactus

you need to completely unindent the last line