mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-25 20:13:57 +01:00
28 lines
758 B
Python
28 lines
758 B
Python
import os
|
|
import aiohttp.web
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
app = aiohttp.web.Application()
|
|
|
|
async def start(client):
|
|
async def get_userinfo():
|
|
guild = client.get_guild(int(os.getenv('DISCORD_GUILD')))
|
|
members = guild.members
|
|
|
|
user_roles = {member.id: [role.name for role in member.roles] for member in members}
|
|
return user_roles
|
|
|
|
async def get_roles(request):
|
|
return aiohttp.web.json_response(await get_userinfo())
|
|
|
|
app.router.add_get('/get_roles', get_roles)
|
|
app.router.add_get('/ping', lambda request: aiohttp.web.Response(text='pong'))
|
|
|
|
runner = aiohttp.web.AppRunner(app)
|
|
await runner.setup()
|
|
site = aiohttp.web.TCPSite(runner, '0.0.0.0', 3224)
|
|
await site.start()
|