From 86bf70907c028b1e54a352ef7ee41574a5a86694 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Mon, 30 Dec 2024 03:51:17 -0500 Subject: [PATCH] refactor: use utils.reply for replying --- arguments.py | 6 ++++-- commands/tools.py | 4 ++-- events.py | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arguments.py b/arguments.py index 30a7cb2..7c96011 100644 --- a/arguments.py +++ b/arguments.py @@ -2,6 +2,8 @@ import argparse import contextlib import io +import utils + class ArgumentParser: def __init__(self, command, description): @@ -24,6 +26,6 @@ class ArgumentParser: args = self.parser.parse_args(tokens[1:]) return args except SystemExit: - await message.reply(f"```\n{self.print_help()}```", mention_author=False) + await utils.reply(message, f"```\n{self.print_help()}```") except Exception as e: - await message.reply(f"`{e}`", mention_author=False) + await utils.reply(message, f"`{e}`") diff --git a/commands/tools.py b/commands/tools.py index c6cb325..ddf5303 100644 --- a/commands/tools.py +++ b/commands/tools.py @@ -57,9 +57,9 @@ async def clear(message): ) ) try: - await message.reply( + await utils.reply( + message, f"purged **{message_count} {'message' if message_count == 1 else 'messages'}**", - mention_author=False, ) except: pass diff --git a/events.py b/events.py index 6cb4925..a02176b 100644 --- a/events.py +++ b/events.py @@ -22,9 +22,9 @@ async def on_message(message): return if len(matched) > 1: - await message.reply( + await utils.reply( + message, f"ambiguous command, could be {' or '.join([f'`{match.value}`' for match in matched])}", - mention_author=False, ) return @@ -95,9 +95,9 @@ async def on_message(message): case C.UPTIME: await commands.bot.uptime(message) except Exception as e: - await message.reply( + await utils.reply( + message, f"exception occurred while processing command: ```\n{''.join(traceback.format_exception(e)).replace('`', '\\`')}```", - mention_author=False, )