How to create a discord bot!

I have found it hard to make a discord bot without Botghost or anything like that,
then I tried Replit and after some time it worked
!I just want to show you the code I used!
This is in Python


# This example requires the 'message_content' intent.
import discord

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

client = discord.Client(intents=intents)

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

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

    if message.content.startswith('hello'):

    if == client.user:

    if message.content.startswith('hi'):
        await'Hi! I am a robot!')'Discord_bot_token')

If you copy and paste it and then change the value up there (to the bots token)
Then run the script and if you did it correct you will get a working bot!!!
Try “Hi” and “Hello”!
Hope this works!

do not put the

This example requires the ‘message_content’ intent.

in the code

Instead of .startswith() I find it easier to just use string indexing since it’s much more concise.

if message.content[:5] == 'hello':
1 Like

Oh, okay, thank you for telling me that,
I will try that