Need help with basic discord bot

Hello, I am new here, getting into the world of coding.

I tried following the basic normal example of:

import discord

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('$hello'):
        await message.channel.send('Hello!')

client.run('your token here')

But I get an error in the .author, .content, .channel and .user
For some reason it lightens in red, not sure what is going on. May someone be able to give me a hand?
I am using Atom IDE (if the info is useful).
Kind regards,
Ezequiel

Hello!

Did you install the discord.py library with pip? If so, the problem may be that the IDE doesn’t recognize the library, which may not present an error.

However, without your actual token it won’t work.

Here’s the documentation for the discord.py library Welcome to discord.py

Hi! I guess I did.
In my Windows CMD I typed

pip install discord.py

I guess that does the job, right?
I am aware about the token thing, but first I tried to see what was the problem here. Any idea?

1 Like

you have your token here, right?

1 Like

In that case your code is OK. The lightens in red part doesn’t actually means it’s an error, it could mean that the IDE doesn’t recognize the variable names (or object properties).

Try it out and see if it works :slight_smile: (replacing your token here with your actual token).

Yes! I do have the token written there.

If I try to compile the code it tells me “Syntax Error”

what/s the whole syntax error that you get?

1 Like

Now none, for some reason now it compiles properly and it works even though I still have the red text!

A mod may close this thread. Thank you!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.