SyntaxError: invalid syntax(trying to make a discord bot :/)

So I was watching a tutorial of how to make a custom discord bot but i got this error and it said that :

File "main.py", line 11
    assync def on_message (message):
    ^
SyntaxError: invalid syntax

here is also the script:

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
  assync def on_message(message):
  if message.athor == client.user:
    return

    if message.content.startwith('$hello'):
      await message.channel.send('Hello!')

      client.run(os.getenv('TOKEN'))
      TOKEN=[REDACTED]

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 (’).

You wrote assync instead of async

p.s. you just gave us your token out so now people can hijack your bot… I would delete that part

2 Likes

Hi @Zxck08 !

Welcome to the forum!

I edited your post so people can’t see your secret token anymore.

Thanks for your help but now it says this
File “main.py”, line 12
if message.author == client.user
^
IndentationError: expected an indented block
i don’t now anything about coding so i don’t now what i need to do and the tutorial doesn’t show any errors

also next time i won’t show my token

indentation is important in python.

But also, it would probably help if you learned some of the basics first before diving into a tutorial like this.

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