|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import ssl |
|
|
|
import discord |
|
|
|
from discord import app_commands |
|
|
|
from discord.ext import commands |
|
|
|
from discord.ext import commands, tasks |
|
|
|
import os, sys |
|
|
|
import aiohttp |
|
|
|
from datetime import datetime |
|
|
|
@ -51,6 +51,21 @@ class DiscordClient(commands.Bot): |
|
|
|
self.loaded_extensions[extension] = __import__(extension).Extension(self) |
|
|
|
sys.path.pop(0) |
|
|
|
|
|
|
|
@tasks.loop(minutes=1) |
|
|
|
async def check_connection(self): |
|
|
|
if os.getenv("ALIVE_PUSH"): |
|
|
|
if not self.is_closed(): |
|
|
|
try: |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.get(os.getenv("ALIVE_PUSH") + f'${round(self.latency * 1000)}', ssl = False) as response: |
|
|
|
tmp = await response.text() |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
|
@check_connection.before_loop |
|
|
|
async def before_check(self): |
|
|
|
await self.wait_until_ready() |
|
|
|
|
|
|
|
async def setup_hook(self): |
|
|
|
await self.GetStats() |
|
|
|
print("sync tree") |
|
|
|
@ -77,6 +92,8 @@ class DiscordClient(commands.Bot): |
|
|
|
print(f"[init.task] {ext_name} have secondary task") |
|
|
|
self.loop.create_task(self.loaded_extensions[ext_name].task_secondary()) |
|
|
|
|
|
|
|
self.check_connection.start() |
|
|
|
|
|
|
|
def setup_events(self): |
|
|
|
@self.event |
|
|
|
async def on_ready(): |
|
|
|
|