[Permissions] Send help on missing argument (#2865)

* [Permissions] Send help on missing argument

Resolves #2851.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* [Permissions] Use varargs instead of Greedy converter

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
Toby Harradine 2019-07-14 11:52:28 +10:00 committed by Michael H
parent 3e80edcdfd
commit 1d2980f8fa

View File

@ -283,7 +283,7 @@ class Permissions(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
allow_or_deny: RuleType, allow_or_deny: RuleType,
cog_or_command: CogOrCommand, cog_or_command: CogOrCommand,
who_or_what: commands.Greedy[GlobalUniqueObjectFinder], *who_or_what: GlobalUniqueObjectFinder,
): ):
"""Add a global rule to a command. """Add a global rule to a command.
@ -294,6 +294,9 @@ class Permissions(commands.Cog):
`<who_or_what>` is one or more users, channels or roles the rule is for. `<who_or_what>` 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: for w in who_or_what:
await self._add_rule( await self._add_rule(
rule=cast(bool, allow_or_deny), rule=cast(bool, allow_or_deny),
@ -311,7 +314,7 @@ class Permissions(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
allow_or_deny: RuleType, allow_or_deny: RuleType,
cog_or_command: CogOrCommand, cog_or_command: CogOrCommand,
who_or_what: commands.Greedy[GuildUniqueObjectFinder], *who_or_what: GuildUniqueObjectFinder,
): ):
"""Add a rule to a command in this server. """Add a rule to a command in this server.
@ -322,6 +325,9 @@ class Permissions(commands.Cog):
`<who_or_what>` is one or more users, channels or roles the rule is for. `<who_or_what>` 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: for w in who_or_what:
await self._add_rule( await self._add_rule(
rule=cast(bool, allow_or_deny), rule=cast(bool, allow_or_deny),
@ -337,7 +343,7 @@ class Permissions(commands.Cog):
self, self,
ctx: commands.Context, ctx: commands.Context,
cog_or_command: CogOrCommand, cog_or_command: CogOrCommand,
who_or_what: commands.Greedy[GlobalUniqueObjectFinder], *who_or_what: GlobalUniqueObjectFinder,
): ):
"""Remove a global rule from a command. """Remove a global rule from a command.
@ -346,6 +352,9 @@ class Permissions(commands.Cog):
`<who_or_what>` is one or more users, channels or roles the rule is for. `<who_or_what>` 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: for w in who_or_what:
await self._remove_rule(cog_or_cmd=cog_or_command, model_id=w.id, guild_id=GLOBAL) await self._remove_rule(cog_or_cmd=cog_or_command, model_id=w.id, guild_id=GLOBAL)
await ctx.send(_("Rule removed.")) await ctx.send(_("Rule removed."))
@ -357,7 +366,7 @@ class Permissions(commands.Cog):
self, self,
ctx: commands.Context, ctx: commands.Context,
cog_or_command: CogOrCommand, cog_or_command: CogOrCommand,
who_or_what: commands.Greedy[GlobalUniqueObjectFinder], *who_or_what: GlobalUniqueObjectFinder,
): ):
"""Remove a server rule from a command. """Remove a server rule from a command.
@ -366,6 +375,9 @@ class Permissions(commands.Cog):
`<who_or_what>` is one or more users, channels or roles the rule is for. `<who_or_what>` 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: for w in who_or_what:
await self._remove_rule( await self._remove_rule(
cog_or_cmd=cog_or_command, model_id=w.id, guild_id=ctx.guild.id cog_or_cmd=cog_or_command, model_id=w.id, guild_id=ctx.guild.id