refactor: improve debgu messages
This commit is contained in:
parent
d6bc67f17a
commit
d56bac1b2f
10
core.py
10
core.py
@ -47,6 +47,8 @@ async def on_message(message, edited=False):
|
||||
match matched[0]:
|
||||
case C.RELOAD if message.author.id in constants.OWNERS:
|
||||
reloaded_modules = set()
|
||||
start = time.time()
|
||||
|
||||
rreload(reloaded_modules, __import__("core"))
|
||||
rreload(reloaded_modules, __import__("extra"))
|
||||
for module in filter(
|
||||
@ -56,6 +58,10 @@ async def on_message(message, edited=False):
|
||||
):
|
||||
rreload(reloaded_modules, module)
|
||||
|
||||
end = time.time()
|
||||
if __debug__:
|
||||
print(f"reloaded {len(reloaded_modules)} in {round(end-start, 2)}s")
|
||||
|
||||
await utils.add_check_reaction(message)
|
||||
case C.EXECUTE if message.author.id in constants.OWNERS:
|
||||
code = message.content[len(tokens[0]) + 1 :].strip().strip("`")
|
||||
@ -126,9 +132,11 @@ async def on_message(message, edited=False):
|
||||
case C.FAST_FORWARD:
|
||||
await commands.voice.fast_forward(message)
|
||||
except Exception as e:
|
||||
formatted_exception = "".join(traceback.format_exception(e))
|
||||
print(formatted_exception)
|
||||
await utils.reply(
|
||||
message,
|
||||
f"exception occurred while processing command: ```\n{''.join(traceback.format_exception(e)).replace('`', '\\`')}```",
|
||||
f"exception occurred while processing command: ```\n{formatted_exception.replace("`", "\\`")}```",
|
||||
)
|
||||
|
||||
|
||||
|
4
tasks.py
4
tasks.py
@ -8,7 +8,7 @@ from state import client, idle_tracker, players
|
||||
|
||||
async def cleanup():
|
||||
while True:
|
||||
await asyncio.sleep(3600)
|
||||
await asyncio.sleep(3600 * 12)
|
||||
|
||||
targets = []
|
||||
for guild_id, player in players.items():
|
||||
@ -16,6 +16,8 @@ async def cleanup():
|
||||
targets.append(guild_id)
|
||||
for target in targets:
|
||||
del players[target]
|
||||
if __debug__:
|
||||
print(f"cleanup removed {len(targets)} empty players")
|
||||
|
||||
if (
|
||||
not idle_tracker["is_idle"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user