Repository: Cog-Creators/Red-DiscordBot

Issue:
[Permissions] Adding a permission for something that doesn't exist returns no error
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

`[p]permissions addglobalrule`

#### What cog is this command from?

Permissions

#### What were you expecting to happen?

The bot says the thing I'm trying to add a rule for something that doesn't exist.

#### What actually happened?

The `discord.Greedy` converter evaluates to 0 things converted, the `for` loop just doesn't run for an empty list (so nothing happens), and the bot says "Rule added."

#### How can we reproduce this issue?

 `[p]permissions addglobalrule allow choose <put_any_random_string_here>`

This might be a case for other commands in the cog as well (any command that uses the Greedy converter).



Discussion:

Resolving patch:
diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py
--- a/redbot/cogs/permissions/permissions.py
+++ b/redbot/cogs/permissions/permissions.py
@@ -283,7 +283,7 @@ async def permissions_addglobalrule(
         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 @@ async def permissions_addglobalrule(
 
         `<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:
             await self._add_rule(
                 rule=cast(bool, allow_or_deny),
@@ -311,7 +314,7 @@ async def permissions_addguildrule(
         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 @@ async def permissions_addguildrule(
 
         `<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:
             await self._add_rule(
                 rule=cast(bool, allow_or_deny),
@@ -337,7 +343,7 @@ async def permissions_removeglobalrule(
         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 @@ async def permissions_removeglobalrule(
 
        `<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:
             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 @@ async def permissions_removeguildrule(
         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 @@ async def permissions_removeguildrule(
 
         `<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:
             await self._remove_rule(
                 cog_or_cmd=cog_or_command, model_id=w.id, guild_id=ctx.guild.id


Test patch: