I try to follow a tutorial on how to host a discord bot with discord.py. I did everything correctly but pyflakes shows a syntax error. Do You know why?
I've got two files: main.py and keep_alive.py. This is main.py:
import os
import discord
from keep_alive import keep_alive
from discord.ext import commands
TOKEN = os.environ('TOKEN')
client = commands.Bot(command_prefix='!')
async def on_ready():
await client.change_presence(activity=discord.ActivityType.listenting('to the server!', status=discord.Status.online)
keep_alive.keep_alive()
client.run(TOKEN, bot=True, reconnect=True)
And this is keep_alive.py:
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "<h1>Your bot is alive!</h1>"
def run():
app.run(host="0.0.0.0", port=8080)
def keep_alive():
server = Thread(target=run)
server.start()`
When I run the program, I get this error:
File "main.py", line 12
keep_alive.keep_alive()
^
SyntaxError: invalid syntax