From 2c4a0921a7a12628db77204fb0f955debf533969 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Tue, 31 Dec 2024 17:41:12 -0500 Subject: [PATCH] feat(commands/tools/clear): add --delete-command --- commands/tools.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/commands/tools.py b/commands/tools.py index 3255083..4bab6f2 100644 --- a/commands/tools.py +++ b/commands/tools.py @@ -55,9 +55,21 @@ async def clear(message): action="store_true", help="delete messages with reactions", ) + parser.add_argument( + "-d", + "--delete-command", + action="store_true", + help="delete the command message as well", + ) if not (args := await parser.parse_args(message, tokens)): return + if args.delete_command: + try: + await message.delete() + except: + pass + regex = None if r := args.regex: regex = re.compile(r, re.IGNORECASE if args.case_insensitive else 0) @@ -83,10 +95,11 @@ async def clear(message): ) ) - try: - await utils.reply( - message, - f"purged **{messages}/{args.count} {'message' if args.count == 1 else 'messages'}**", - ) - except: - pass + if not args.delete_command: + try: + await utils.reply( + message, + f"purged **{messages}/{args.count} {'message' if args.count == 1 else 'messages'}**", + ) + except: + pass