I am trying write discord bots using Python, I have come across and threw together this bot.
import discord import asyncio import random client = discord.Client() inEmail = input("Email:") inPassword = input("Passwd:") async def background_loop(): await client.wait_until_ready() while not client.is_closed: channel = client.get_channel("************") messages = ["Hello!", "How are you doing?", "Testing!!"] await client.send_message(channel, random.choice(messages)) await asyncio.sleep(120) client.loop.create_task(background_loop()) client.run(inEmail, inPassword)
Yet when I tried to run it, I received a
File "1.py", line 7 async def background_loop(): ^ SyntaxError: invalid syntax
Why is that? I have never received that before when I tested it.