refactor: use utils.reply for replying
This commit is contained in:
parent
6b9172ef1b
commit
86bf70907c
@ -2,6 +2,8 @@ import argparse
|
|||||||
import contextlib
|
import contextlib
|
||||||
import io
|
import io
|
||||||
|
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
class ArgumentParser:
|
class ArgumentParser:
|
||||||
def __init__(self, command, description):
|
def __init__(self, command, description):
|
||||||
@ -24,6 +26,6 @@ class ArgumentParser:
|
|||||||
args = self.parser.parse_args(tokens[1:])
|
args = self.parser.parse_args(tokens[1:])
|
||||||
return args
|
return args
|
||||||
except SystemExit:
|
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:
|
except Exception as e:
|
||||||
await message.reply(f"`{e}`", mention_author=False)
|
await utils.reply(message, f"`{e}`")
|
||||||
|
@ -57,9 +57,9 @@ async def clear(message):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await message.reply(
|
await utils.reply(
|
||||||
|
message,
|
||||||
f"purged **{message_count} {'message' if message_count == 1 else 'messages'}**",
|
f"purged **{message_count} {'message' if message_count == 1 else 'messages'}**",
|
||||||
mention_author=False,
|
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -22,9 +22,9 @@ async def on_message(message):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if len(matched) > 1:
|
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])}",
|
f"ambiguous command, could be {' or '.join([f'`{match.value}`' for match in matched])}",
|
||||||
mention_author=False,
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -95,9 +95,9 @@ async def on_message(message):
|
|||||||
case C.UPTIME:
|
case C.UPTIME:
|
||||||
await commands.bot.uptime(message)
|
await commands.bot.uptime(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await message.reply(
|
await utils.reply(
|
||||||
|
message,
|
||||||
f"exception occurred while processing command: ```\n{''.join(traceback.format_exception(e)).replace('`', '\\`')}```",
|
f"exception occurred while processing command: ```\n{''.join(traceback.format_exception(e)).replace('`', '\\`')}```",
|
||||||
mention_author=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user