From e74a3b0bc3dc840800f032c31ce5a3e9e6add6a0 Mon Sep 17 00:00:00 2001 From: Myned Date: Sat, 28 Oct 2017 15:40:14 -0400 Subject: [PATCH] Optimized arg cleaning --- src/main/utils/utils.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py index 71e5eb1..cf323c8 100644 --- a/src/main/utils/utils.py +++ b/src/main/utils/utils.py @@ -117,19 +117,17 @@ def get_kwargs(ctx, args, *, limit=False): rm = False lim = 1 - if '-d' in remaining or '-dm' in remaining: - destination = ctx.author + for flag in ('-d', '-dm'): + if flag in remaining: + destination = ctx.author - for flag in ('-d', '-dm'): - with suppress(ValueError): - remaining.remove(flag) + remaining.remove(flag) - if ('-r' in remaining or '-rm' in remaining or '-remove' in remaining) and ctx.author.permissions_in(ctx.channel).manage_messages: - rm = True + for flag in ('-r', '-rm', '-remove', '-re', '-repl', '-replace'): + if flag in remaining and ctx.author.permissions_in(ctx.channel).manage_messages: + rm = True - for flag in ('-r', '-rm', '-remove'): - with suppress(ValueError): - remaining.remove(flag) + remaining.remove(flag) if limit: for arg in remaining: