[commands] Make Greedy ignore parsing errors.
This commit is contained in:
parent
def012e281
commit
1179df7e29
@ -500,10 +500,10 @@ class Command(_BaseCommand):
|
|||||||
previous = view.index
|
previous = view.index
|
||||||
|
|
||||||
view.skip_ws()
|
view.skip_ws()
|
||||||
argument = view.get_quoted_word()
|
|
||||||
try:
|
try:
|
||||||
|
argument = view.get_quoted_word()
|
||||||
value = await self.do_conversion(ctx, converter, argument, param)
|
value = await self.do_conversion(ctx, converter, argument, param)
|
||||||
except CommandError:
|
except (CommandError, ArgumentParsingError):
|
||||||
view.index = previous
|
view.index = previous
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -516,10 +516,10 @@ class Command(_BaseCommand):
|
|||||||
async def _transform_greedy_var_pos(self, ctx, param, converter):
|
async def _transform_greedy_var_pos(self, ctx, param, converter):
|
||||||
view = ctx.view
|
view = ctx.view
|
||||||
previous = view.index
|
previous = view.index
|
||||||
argument = view.get_quoted_word()
|
|
||||||
try:
|
try:
|
||||||
|
argument = view.get_quoted_word()
|
||||||
value = await self.do_conversion(ctx, converter, argument, param)
|
value = await self.do_conversion(ctx, converter, argument, param)
|
||||||
except CommandError:
|
except (CommandError, ArgumentParsingError):
|
||||||
view.index = previous
|
view.index = previous
|
||||||
raise RuntimeError() from None # break loop
|
raise RuntimeError() from None # break loop
|
||||||
else:
|
else:
|
||||||
@ -1498,7 +1498,7 @@ def bot_has_any_role(*items):
|
|||||||
def has_permissions(**perms):
|
def has_permissions(**perms):
|
||||||
"""A :func:`.check` that is added that checks if the member has all of
|
"""A :func:`.check` that is added that checks if the member has all of
|
||||||
the permissions necessary.
|
the permissions necessary.
|
||||||
|
|
||||||
Note that this check operates on the current channel permissions, not the
|
Note that this check operates on the current channel permissions, not the
|
||||||
guild wide permissions.
|
guild wide permissions.
|
||||||
|
|
||||||
@ -1561,44 +1561,44 @@ def bot_has_permissions(**perms):
|
|||||||
def has_guild_permissions(**perms):
|
def has_guild_permissions(**perms):
|
||||||
"""Similar to :func:`.has_permissions`, but operates on guild wide
|
"""Similar to :func:`.has_permissions`, but operates on guild wide
|
||||||
permissions instead of the current channel permissions.
|
permissions instead of the current channel permissions.
|
||||||
|
|
||||||
If this check is called in a DM context, it will raise an
|
If this check is called in a DM context, it will raise an
|
||||||
exception, :exc:`.NoPrivateMessage`.
|
exception, :exc:`.NoPrivateMessage`.
|
||||||
|
|
||||||
.. versionadded:: 1.3.0
|
.. versionadded:: 1.3.0
|
||||||
"""
|
"""
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if not ctx.guild:
|
if not ctx.guild:
|
||||||
raise NoPrivateMessage
|
raise NoPrivateMessage
|
||||||
|
|
||||||
permissions = ctx.author.guild_permissions
|
permissions = ctx.author.guild_permissions
|
||||||
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
|
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
|
||||||
|
|
||||||
if not missing:
|
if not missing:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
raise MissingPermissions(missing)
|
raise MissingPermissions(missing)
|
||||||
|
|
||||||
return check(predicate)
|
return check(predicate)
|
||||||
|
|
||||||
def bot_has_guild_permissions(**perms):
|
def bot_has_guild_permissions(**perms):
|
||||||
"""Similar to :func:`.has_guild_permissions`, but checks the bot
|
"""Similar to :func:`.has_guild_permissions`, but checks the bot
|
||||||
members guild permissions.
|
members guild permissions.
|
||||||
|
|
||||||
.. versionadded:: 1.3.0
|
.. versionadded:: 1.3.0
|
||||||
"""
|
"""
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if not ctx.guild:
|
if not ctx.guild:
|
||||||
raise NoPrivateMessage
|
raise NoPrivateMessage
|
||||||
|
|
||||||
permissions = ctx.me.guild_permissions
|
permissions = ctx.me.guild_permissions
|
||||||
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
|
missing = [perm for perm, value in perms.items() if getattr(permissions, perm, None) != value]
|
||||||
|
|
||||||
if not missing:
|
if not missing:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
raise BotMissingPermissions(missing)
|
raise BotMissingPermissions(missing)
|
||||||
|
|
||||||
return check(predicate)
|
return check(predicate)
|
||||||
|
|
||||||
def dm_only():
|
def dm_only():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user