import os
import discord
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!')
my_secret = os.environ['TOKEN']
client.run(my_secret)
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
https://discordpy.readthedocs.io/en/stable/quickstart.html
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
system
Closed
February 10, 2022, 4:50am
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.