Я пытаюсь сделать сайт с донатом (т.е когда человек покупает донат ему дается роль в дискорде)
index.py
import discord, asyncio
from quart import Quart
app = Quart(__name__)
bot = discord.Client(intents = discord.Intents().all())
@app.before_serving
async def before_serving():
loop = asyncio.get_event_loop()
await bot.login("токен")
loop.create_task(bot.connect())
@app.route("/", methods=["GET"])
async def index():
guild = bot.get_guild(699607137227243550)
members = guild.members
bots = len([m for m in members if m.bot])
users = len(members) - bots
online = len(list(filter(lambda x: x.status == discord.Status.online, members))) + len(list(filter(lambda x: x.status == discord.Status.idle, members))) + len(list(filter(lambda x: x.status == discord.Status.dnd, members)))
online_b = len(list(filter(lambda x: x.status == discord.Status.online, [m for m in members if m.bot]))) + len(list(filter(lambda x: x.status == discord.Status.idle, [m for m in members if m.bot]))) + len(list(filter(lambda x: x.status == discord.Status.dnd, [m for m in members if m.bot])))
online = online - online_b
return f'''
Участников на сервере: {users}
Онлайн: {online}
''', 200
if __name__ == "__main__":
app.run()
requirements.txt
quart
discord.py
Использую хостинг Vercel, python 3.9.13
Бот на сервере есть
Ошибка на хостинге
[ERROR] 2022-09-07T13:05:17.933Z 9f08875a-be95-41b2-8207-380fb8671adb Exception on request GET /
Traceback (most recent call last):
File "/var/task/quart/app.py", line 1629, in handle_request
return await self.full_dispatch_request(request_context)
File "/var/task/quart/app.py", line 1654, in full_dispatch_request
result = await self.handle_user_exception(error)
File "/var/task/quart/app.py", line 1099, in handle_user_exception
raise error
File "/var/task/quart/app.py", line 1652, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "/var/task/quart/app.py", line 1697, in dispatch_request
return await self.ensure_async(handler)(**request_.view_args)
File "./index.py", line 17, in index
members = guild.members
AttributeError: 'NoneType' object has no attribute 'members'