From 1d2980f8fa45e3f089b9369d2ef19f7dd4c51d2c Mon Sep 17 00:00:00 2001 From: Toby Harradine Date: Sun, 14 Jul 2019 11:52:28 +1000 Subject: [PATCH] [Permissions] Send help on missing argument (#2865) * [Permissions] Send help on missing argument Resolves #2851. Signed-off-by: Toby Harradine * [Permissions] Use varargs instead of Greedy converter Signed-off-by: Toby Harradine --- redbot/cogs/permissions/permissions.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py index bb27669b1..2af4cfc88 100644 --- a/redbot/cogs/permissions/permissions.py +++ b/redbot/cogs/permissions/permissions.py @@ -283,7 +283,7 @@ class Permissions(commands.Cog): ctx: commands.Context, allow_or_deny: RuleType, cog_or_command: CogOrCommand, - who_or_what: commands.Greedy[GlobalUniqueObjectFinder], + *who_or_what: GlobalUniqueObjectFinder, ): """Add a global rule to a command. @@ -294,6 +294,9 @@ class Permissions(commands.Cog): `` is one or more users, channels or roles the rule is for. """ + if not who_or_what: + await ctx.send_help() + return for w in who_or_what: await self._add_rule( rule=cast(bool, allow_or_deny), @@ -311,7 +314,7 @@ class Permissions(commands.Cog): ctx: commands.Context, allow_or_deny: RuleType, cog_or_command: CogOrCommand, - who_or_what: commands.Greedy[GuildUniqueObjectFinder], + *who_or_what: GuildUniqueObjectFinder, ): """Add a rule to a command in this server. @@ -322,6 +325,9 @@ class Permissions(commands.Cog): `` is one or more users, channels or roles the rule is for. """ + if not who_or_what: + await ctx.send_help() + return for w in who_or_what: await self._add_rule( rule=cast(bool, allow_or_deny), @@ -337,7 +343,7 @@ class Permissions(commands.Cog): self, ctx: commands.Context, cog_or_command: CogOrCommand, - who_or_what: commands.Greedy[GlobalUniqueObjectFinder], + *who_or_what: GlobalUniqueObjectFinder, ): """Remove a global rule from a command. @@ -346,6 +352,9 @@ class Permissions(commands.Cog): `` is one or more users, channels or roles the rule is for. """ + if not who_or_what: + await ctx.send_help() + return for w in who_or_what: await self._remove_rule(cog_or_cmd=cog_or_command, model_id=w.id, guild_id=GLOBAL) await ctx.send(_("Rule removed.")) @@ -357,7 +366,7 @@ class Permissions(commands.Cog): self, ctx: commands.Context, cog_or_command: CogOrCommand, - who_or_what: commands.Greedy[GlobalUniqueObjectFinder], + *who_or_what: GlobalUniqueObjectFinder, ): """Remove a server rule from a command. @@ -366,6 +375,9 @@ class Permissions(commands.Cog): `` is one or more users, channels or roles the rule is for. """ + if not who_or_what: + await ctx.send_help() + return for w in who_or_what: await self._remove_rule( cog_or_cmd=cog_or_command, model_id=w.id, guild_id=ctx.guild.id