Python Discord Bot doesn't work, shows NO errors

I was following the YT tutorial on how to code a Discord bot on Python, and after writing the exact code as the video showed and following the exact same steps, the bot still does nothing when i give it commands.

The video I am referring to is Code a Discord Bot with Python - Host for Free in the Cloud - YouTube

Here’s the code I wrote, did I do anything wrong but can’t see it?

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


client.run(os.getenv('TOKEN'))

indentation is an important syntax feature in python, it indicates what’s inside of what
if your indentation doesn’t match it is not going to do the same thing

1 Like

Thank you so much! It works now.

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