Discord Bot Course Help

import os
import discord

client = discord.Client()

async def on_ready():
  print('We have logged in as {0.user} '.format(client))

  async def on_message(message):
    if message.author == client.user:

      if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

my_secret = os.environ['TOKEN']

This is my code for my bot and when I enter $hello in a channel nothing happens

HI @cristilio !

Welcome to the forum!

It doesn’t look like your starting code is correct.

That second if statements looks like it is nested inside the first one by the way you chose to indent it.

I would review the starter code provided by the official discord.py docs.
It is the exact same code used in the video

1 Like

Yess! Worked like a charm Thank You for the Help! am new to the language I moved from c# to python so I thought you could place it anywhere you want (still using the methods of brackets) so yea that’s why I made that mistake. I was wondering what was wrong for 30 minutes straight but this helped. Thank You once again!

1 Like

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