Reputation:
I am trying to make a Discord bot with this code, however I get this error in the terminal. I know about I get a syntax error when I import discord in the cmd but not in vs code, but it does not solve the issue I am having.
from discord.ext import commands
from utils.logger import Logger
logger = Logger().logger
glados_cores = ["cogs.angry_core"]
bot = commands.Bot(command_prefix="!")
bot.logger = logger
@bot.event
async def on_ready():
logger.info("---------------bot-ready---------------")
logger.info("Hello and, again, welcome to the Aperture Science computer-aided enrichment center.")
if __name__ == "__main__":
for extension in glados_cores:
try:
bot.load_extension(extension)
except Exception as e:
exc = f"{type(e).__name__}: {e}"
logger.info(f"{exc} Failed to load extension {extension}")
bot.run(TOKEN)
I keep getting this syntax error when I try to run the code:
COMPUTER:Genetic-Lifeform-and-Disk-Operating-System-master COMPUTER$ python main.py
File "main.py", line 11
async def on_ready():
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 1190
Reputation: 409
This happens if you do not have python 3.5+. If you get a syntax error in cmd it's likely because you have python <3.5 installed on your path.
Upvotes: 2