**I am trying to code a bot for discord, but I do not have a laptop or an android. The chromebook I have is a school owned one, so things like downloads and developer mode are blocked. I can’t get the linux demo either. If it is not possible to code on this through web, then I do have an Iphone, which I have been told is impossible to code on… I’m not worried about how long the code takes to develop, I just want to be able to code it without any laptop.
Additionally, all attempts to use a code given with this website: https://github.com/Rapptz/discord.py/tree/async
I enter this example:
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!test'):
counter = 0
tmp = await client.send_message(message.channel, 'Calculating messages...')
async for log in client.logs_from(message.channel, limit=100):
if log.author == message.author:
counter += 1
await client.edit_message(tmp, 'You have {} messages.'.format(counter))
elif message.content.startswith('!sleep'):
await asyncio.sleep(5)
await client.send_message(message.channel, 'Done sleeping')
client.run('token')
but it gives me a syntax error like this:
Unknown Error.
File "<stdin>", line 7
async def on_ready():
^
SyntaxError: invalid syntax
Unknown Error.
This is insanely frustrating… can someone assist?
(i am using https://thumbsdb.herokuapp.com/python/?state={"folderId":"0AIiLka239X73Uk9PVA","action":"create","userId":"117443184978319349054"} and https://www.onlinegdb.com/ to enter and run code)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there @eX2ii2t,
This error normally means that you’re using a version of Python that does not support async syntax. This is normally Python 2.x
Looking at the website you linked, it does indeed appear that it is using Python 2, which is why your program is not working.
You’ll need to find an online editor that supports Python 3.5+, as documented in the GitHub repository for this library: https://github.com/Rapptz/discord.py
(As a side note, the async branch of the library is no longer maintained and you should use the version of the library contained within master, which is available on PyPi.org)
Hope that helps! - Matt.