Ask coding questions

← Back to all posts
Does anyone know what i need to do to fix this?
drurythom2304 (1)

I need a bit of help wth some coding thx

Comments
hotnewtop
catspython (28)

look at line 20, then change

if message.content.startswith("Hp"):await 
  message.channel.send("Hg   Hr   Hh   Hs")

to

if message.content.startswith("Hp"):
  await message.channel.send("Hg   Hr   Hh   Hs")
drurythom2304 (1)

that makes the whole thing an error
@catspython

catspython (28)

@drurythom2304 give me a screen shot of the error

catspython (28)

@drurythom2304 The error is because you didn't make the change to put await down a line.

Coder100 (18148)

Ya put the if statements the wrong place

Put them inside the on_message function.

drurythom2304 (1)

@Coder100 dude im new to dis stuff do u know what i do?

robowolf (549)

Line 42 has a space. Put it at the very edge or indent it properly into line 39's if statement to fix it.

ch1ck3n (2055)
import discord
import os

client = discord.Client() 

@client.event
async def on_ready():
  print("We have logged in a {0.user}            ".format(client))

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

 if message.author.startswith("$hello"):
   await message.channel.send("Hello!")

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

if message.content.startswith("Hp"):
   await message.channel.send("Hg   Hr   Hh   Hs")

if message.content.startswith("Hg"):
   await message.channel.send("You Have chosen Gryfindor")

if message.content.startswith("Hgme"):
   await message.channel.send("Me, Gryfindor, Lion guard, Professor Mcgonagal's Prize Pupil")

if message.content.startswith("Hr"):
   await message.channel.send("You have chosen Ravenclaw")
if message.content.startswith("Hrme"):
    await message.channel.send("Me, Ravenclaw, Predator Bird, Professor Flitwick's Prize Pupil")
   
if message.content.startswith("Hh"):
    await message.channel.send("You have chosen Hufflepuff")
if message.content.startswith("Hhme"):
  await message.channel.send("Me, Hufflepuff, Honey Hunter, Professor Sprouts Plantologist")
  
if message.content.startswith("Hs"):
    await message.channel.send("You have chosen Slytherin")
 
if message.content.startswith("Hsme"): 
    await message.channel.send("Me, Slytherin, Cold Blood Killer Professor Snapes Top Student")
PYTHORE3605 (140)

Your indents don't match up. go into setting in the repl and change it and then you have to go back and re indent everything (ik it sucks but it is something you have to do sometimes)