Files
zyrarbot/main.py
T

28 lines
802 B
Python

import asyncio
import uvicorn
from bot import bot, TOKEN
from web import app
async def main():
async with bot:
config = uvicorn.Config(app, host="0.0.0.0", port=8000, log_level="info")
server = uvicorn.Server(config)
server_task = asyncio.create_task(server.serve())
try:
await bot.start(TOKEN)
except Exception as e:
print(f"Error starting Discord bot: {e}")
print("Keep running FastAPI web server...")
while not server.should_exit:
try:
await asyncio.sleep(1)
except asyncio.CancelledError:
break
finally:
server.should_exit = True
await server_task
if __name__ == "__main__":
asyncio.run(main())