1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 00:47:44 +00:00

feat: async Bot run

This commit is contained in:
RGBCube 2025-04-07 01:26:43 +03:00
parent efb078fef9
commit fb63e83312
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
2 changed files with 14 additions and 17 deletions

View file

@ -2,7 +2,6 @@ from __future__ import annotations
__all__ = ("MinearchyBot",)
import asyncio
from inspect import cleandoc as strip
from itertools import chain
from pathlib import Path
@ -83,16 +82,10 @@ class MinearchyBot(CommandsBot):
except (ExtensionFailed, NoEntryPointError):
print(f"Couldn't load {file_name}:\n{format_exception()}")
def run(self) -> None:
async def runner() -> None:
async with self, AIOHTTPSession() as self.session:
self.log_webhook = Webhook.from_url(
self.webhook_url, session = self.session, bot_token = self.token
)
await self.load_extensions()
await self.start(self.token)
try:
asyncio.run(runner())
except KeyboardInterrupt:
pass
async def run(self) -> None:
async with self, AIOHTTPSession() as self.session:
self.log_webhook = Webhook.from_url(
self.webhook_url, session = self.session, bot_token = self.token
)
await self.load_extensions()
await self.start(self.token)