feat(commands/tools/clear): add --delete-command

This commit is contained in:
Ryan 2024-12-31 17:41:12 -05:00
parent d78bcc4c69
commit 2c4a0921a7
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -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