aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-12-17 00:27:56 -0500
committerRapptz <[email protected]>2019-12-17 00:27:56 -0500
commit1179df7e292ac10953e4f86acbf2ccf1eb670958 (patch)
tree07003405dda5884795e759d59bf01304ae042b47
parentBe more explicit in the utils.find example code. (diff)
downloaddiscord.py-1179df7e292ac10953e4f86acbf2ccf1eb670958.tar.xz
discord.py-1179df7e292ac10953e4f86acbf2ccf1eb670958.zip
[commands] Make Greedy ignore parsing errors.
-rw-r--r--discord/ext/commands/core.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 5f6aca16..5754acc4 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -500,10 +500,10 @@ class Command(_BaseCommand):
previous = view.index
view.skip_ws()
- argument = view.get_quoted_word()
try:
+ argument = view.get_quoted_word()
value = await self.do_conversion(ctx, converter, argument, param)
- except CommandError:
+ except (CommandError, ArgumentParsingError):
view.index = previous
break
else:
@@ -516,10 +516,10 @@ class Command(_BaseCommand):
async def _transform_greedy_var_pos(self, ctx, param, converter):
view = ctx.view
previous = view.index
- argument = view.get_quoted_word()
try:
+ argument = view.get_quoted_word()
value = await self.do_conversion(ctx, converter, argument, param)
- except CommandError:
+ except (CommandError, ArgumentParsingError):
view.index = previous
raise RuntimeError() from None # break loop
else:
@@ -1498,7 +1498,7 @@ def bot_has_any_role(*items):
def has_permissions(**perms):
"""A :func:`.check` that is added that checks if the member has all of
the permissions necessary.
-
+
Note that this check operates on the current channel permissions, not the
guild wide permissions.
@@ -1561,44 +1561,44 @@ def bot_has_permissions(**perms):
def has_guild_permissions(**perms):
"""Similar to :func:`.has_permissions`, but operates on guild wide
permissions instead of the current channel permissions.
-
+
If this check is called in a DM context, it will raise an
exception, :exc:`.NoPrivateMessage`.
-
+
.. versionadded:: 1.3.0
"""
def predicate(ctx):
if not ctx.guild:
raise NoPrivateMessage
-
+
permissions = ctx.author.guild_permissions
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
-
+
if not missing:
return True
-
+
raise MissingPermissions(missing)
-
+
return check(predicate)
def bot_has_guild_permissions(**perms):
"""Similar to :func:`.has_guild_permissions`, but checks the bot
members guild permissions.
-
+
.. versionadded:: 1.3.0
"""
def predicate(ctx):
if not ctx.guild:
raise NoPrivateMessage
-
+
permissions = ctx.me.guild_permissions
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
-
+
if not missing:
return True
-
+
raise BotMissingPermissions(missing)
-
+
return check(predicate)
def dm_only():