1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 00:47:44 +00:00
This commit is contained in:
RGBCube 2022-12-17 20:41:40 +03:00
parent 5b7fb2deba
commit 5ab80712d0
6 changed files with 45 additions and 36 deletions

View file

@ -2,12 +2,12 @@ from __future__ import annotations
__all__ = ("MinearchyBot",)
from asyncio import run as run_coro
from inspect import cleandoc as strip_doc
from itertools import chain as chain_iter
import asyncio
from inspect import cleandoc as strip
from itertools import chain
from pathlib import Path
from time import time as current_time
from traceback import format_exc as format_exit
from time import time as get_time
from traceback import format_exc as format_exception
from aiohttp import ClientSession as AIOHTTPSession
from discord import AllowedMentions, Game, Intents, Webhook
@ -58,7 +58,7 @@ class MinearchyBot(CommandsBot):
@override
async def on_ready(self) -> None:
print(
strip_doc(
strip(
f"""
Connected to Discord!
User: {self.user}
@ -67,12 +67,12 @@ class MinearchyBot(CommandsBot):
)
)
self.ready_timestamp = current_time()
self.ready_timestamp = get_time()
await self.log_webhook.send("Bot is now online!")
async def load_extensions(self) -> None:
cogs = Path(__file__).parent / "cogs"
for file_name in chain_iter(
for file_name in chain(
map(
lambda file_path: ".".join(file_path.relative_to(cogs.parent.parent).parts)[:-3],
cogs.rglob("*.py"),
@ -83,7 +83,7 @@ class MinearchyBot(CommandsBot):
await self.load_extension(file_name)
print(f"Loaded {file_name}")
except (ExtensionFailed, NoEntryPointError):
print(f"Couldn't load {file_name}:\n{format_exit()}")
print(f"Couldn't load {file_name}:\n{format_exception()}")
@override
def run(self) -> None:
@ -96,6 +96,6 @@ class MinearchyBot(CommandsBot):
await self.start(self.token, reconnect=True)
try:
run_coro(runner())
asyncio.run(runner())
except KeyboardInterrupt:
pass