Having trouble with discord bot from python tutorial

Why are you saving the token in my_secret and then not using it? Pass that variable to the run method.

Edit: also please post code and not images.

we watched the same video so i used “TOKEN” as the secret too. also i did put client.run as the last line

I redid it and now it says theres something wrong with line 15, though i dont see a problem


idk its just not woeking

Hi @stunna61 !

It looks like you are missing a colon at the end of your if statement for line 15.


help me to fix it plssssssssssssssssssssss

Hi @silent123gg !

Welcome to the forum!

Usually when that error message pops up, that means there is a mix of tabs and spaces.

Try the indentation again with just spaces.

Also, it would help a lot more if you post your code directly into the forum and not post screenshots.
Thanks!

will the is my first ti
me codeing sooooooooo iam kanida stupid in this

It’s ok you are fine.
We were all beginners once :grinning:

but for real i did nor under stand any word of what you just said

and there is no proplem in there i am very sure its just makeing this

i fixed my punctuation now im getting this.

As I mentioned earlier, it would help if you shared the replit link.
That way I could fork it and play around with the code myself to see and fix the issue.


In python, indentation matters.
Unlike other languages like JavaScript, python cares about how you indent your code.

Here is an explanation from python.org

Look under the tabs and spaces section

import discord    
import os

client = discord .Client()

@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('>help'):
    await message.channel.send('HELLOS SIR!')



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

can you also help me with my coding im just very confused too : DD

this is mine pls fix it plssssssssssssssssssssssssssssss

but dont see the replays from the sad words bc its a joke with my friend :grinning: :grimacing:

For replit, these are the steps I followed to connect and run my bot.

I will make a separate post, for others to follow but here are the screenshots for now.

Click on the lock icon
click on secrets tab

Add your key and bot value

You are already inserted import os
But you also have to insert the variable
insert your token

Then you add the my_secret variable to the your client.run
add my_secret variable

If you are successful you should see this when you run the bot

Also, I think it should be lower case c for client because that is what the docs have.

Here is the exact starter code from the docs.
https://discordpy.readthedocs.io/en/stable/quickstart.html

I would just copy that, get your bot working, then change the message here to whatever you want here.

startswith('$hello'):

ya for me thats not only the proplem

Please see the screenshots I replied with on how to setup the variable and connect your bot.

See if that works.

Edit:
Also, try just using TOKEN for the key name in your secrets tab.
I don’t know if it support your current name of