Discord Bot Python

Hello could somebody help me with this code, because when I try running the code it says there is an error.

import discord
import os

intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)

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

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

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


I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Okey, will do next time.

Is there anyway you can provide what the error mentions?
Here’s a quick example from Rapptz Discord Py Documentation.

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)

async def ping(ctx):
    await ctx.send('pong')


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