Question
How do I code a Discord Bot in Python on an Iphone or Chromebook?
**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=%7B%22folderId%22:%220AIiLka239X73Uk9PVA%22,%22action%22:%22create%22,%22userId%22:%22117443184978319349054%22%7D and https://www.onlinegdb.com/ to enter and run code)
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.
×
This is because you need to put parentheses after client.event
So it should look like this
Client.event()
async def on_ready():
Also, async should not have caps