SYNTAX ERROR!!!!!!!!!!!
I have no clue what's the syntax error the tutorial matches my code. Here's the screenshot of the tutorial.
Solution
This is because you aren't closing your quotes. You have a print
statement, but you aren't closing it.
import discord import os 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!') client.run(os.getenv('TOKEN'))
like that.
That should work
THANK YOU SO [email protected]
Basically the issue is that you never closed the quotes. The reason why this is is because the person who made the tutorial had text wrapping since the console was expanded or the screen wasn't that big. you can solve it by putting the end quote on the previous line.
@alanchen12 THANK YOU SO MUch I’m in my early teens so I didn’t really understand much but would you mind showing an example of putting the end quote on the previous line?
Instead of
print('We have logged in as {0.user} '.format(client))
use
print('We have logged in as {0.user}'.format(client))
THANK YOU SO MUCH @alanchen12
The indent on lines 11-18 are unnecessary: it shouldn't have a tab in front. Also, line 9 should be on the same line as line 8, it just looks like that because the text is wrapping. Here's a fixed version
The reason you are getting this error is because Python is having an issue with the missing quote and closing bracket on line 8.
THANK YOU GUYS SO [email protected]
Error:
You aren't closing your print statement.
Correct code:
import discord
import os
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!')
THANK YOU SO [email protected]