discord bot not working

so i got this code in repl (look picture):

import discord
import os
client = discord.Client() 

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

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

 if message.content.startswith('$hello'):
   await ('hello bitch')'TOKEN'))

and if i run it nothing is happening. The code just shuts down immediatly. i try to make a discord bot.

Welcome there,

I’ve edited your post 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 (’).

indentation is part of python syntax, you have made so that this is not called

which is what creates the connection with the discord bot, as you put it inside an if statement that execute only in response to an event in the server, so it will never be called

Oh yeah i see thank you both

you have to get your bots token then it will be fine to do it go on the webpage of it the dev page it should be in bot settings

For some reason, I was getting a 429 error when trying out this code a couple days ago. But now it seems to be working just fine!

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