|
|
@ -23,6 +23,7 @@ class DiscordClient(commands.Bot): |
|
|
|
stats = {} |
|
|
|
show_stats_prev = 0 |
|
|
|
loaded_extensions = {} |
|
|
|
api_down = True |
|
|
|
|
|
|
|
def __init__(self, backend_url, secret_key): |
|
|
|
self.backend_url = backend_url |
|
|
@ -57,6 +58,8 @@ class DiscordClient(commands.Bot): |
|
|
|
await self.tree.sync(guild=discord.Object(self.main_server_id)) |
|
|
|
await self.tree.sync() |
|
|
|
|
|
|
|
await self.core.wait_until_ready() |
|
|
|
|
|
|
|
print(f"[init] check exts for have prepairs") |
|
|
|
for ext_name, ext in self.loaded_extensions.items(): |
|
|
|
if getattr(ext, "prepair", None): |
|
|
@ -137,9 +140,14 @@ class DiscordClient(commands.Bot): |
|
|
|
return player |
|
|
|
|
|
|
|
async def GetStats(self): |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.get(f"{os.getenv('BACKEND_URL')}/api/stats", ssl=False) as response: |
|
|
|
self.stats = await response.json() |
|
|
|
try: |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.get(f"{os.getenv('BACKEND_URL')}/api/stats", ssl=False) as response: |
|
|
|
self.stats = await response.json() |
|
|
|
self.api_down = False |
|
|
|
except Exception as e: |
|
|
|
self.api_down = True |
|
|
|
raise e |
|
|
|
return self.stats |
|
|
|
|
|
|
|
def GetServersChoice(self): |
|
|
|