Repository: Cog-Creators/Red-DiscordBot

Issue:
[Permissions] Allow for mutiple IDs in permissions
# Feature request

#### Select the type of feature you are requesting:

- [x] Cog
- [x] Command
- [ ] API functionality

#### Describe your requested feature

This idea is quite a simple one but I think this will go a long way in the usability and the speed of setting up permissions on the bot. Lets say I want to give a set of members the kick command (assuming kick is default deny all) without giving an role access to this. then I would type in:
``p addguildrule allow kick UserID1``
``p addguildrule allow kick UserID2``
etc.

However to greatly improve the speed at which this can be done we could allow the user to specify multiple IDs at once. As example:
``p addguildrule allow kick UserID1 UserID2 UserID3``

This might also work with commands and cogs to allow multiple of those in one go, but I suspect that would be much harder to implement correctly.


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
@@ -278,7 +278,7 @@ async def permissions_addglobalrule(
         ctx: commands.Context,
         allow_or_deny: RuleType,
         cog_or_command: CogOrCommand,
-        who_or_what: GlobalUniqueObjectFinder,
+        who_or_what: commands.Greedy[GlobalUniqueObjectFinder],
     ):
         """Add a global rule to a command.
 
@@ -287,15 +287,15 @@ async def permissions_addglobalrule(
         `<cog_or_command>` is the cog or command to add the rule to.
         This is case sensitive.
 
-        `<who_or_what>` is the user, channel, role or server the rule
-        is for.
+        `<who_or_what>` is one or more users, channels or roles the rule is for.
         """
-        await self._add_rule(
-            rule=cast(bool, allow_or_deny),
-            cog_or_cmd=cog_or_command,
-            model_id=who_or_what.id,
-            guild_id=0,
-        )
+        for w in who_or_what:
+            await self._add_rule(
+                rule=cast(bool, allow_or_deny),
+                cog_or_cmd=cog_or_command,
+                model_id=w.id,
+                guild_id=0,
+            )
         await ctx.send(_("Rule added."))
 
     @commands.guild_only()
@@ -306,7 +306,7 @@ async def permissions_addguildrule(
         ctx: commands.Context,
         allow_or_deny: RuleType,
         cog_or_command: CogOrCommand,
-        who_or_what: GuildUniqueObjectFinder,
+        who_or_what: commands.Greedy[GuildUniqueObjectFinder],
     ):
         """Add a rule to a command in this server.
 
@@ -315,14 +315,15 @@ async def permissions_addguildrule(
         `<cog_or_command>` is the cog or command to add the rule to.
         This is case sensitive.
 
-        `<who_or_what>` is the user, channel or role the rule is for.
+        `<who_or_what>` is one or more users, channels or roles the rule is for.
         """
-        await self._add_rule(
-            rule=cast(bool, allow_or_deny),
-            cog_or_cmd=cog_or_command,
-            model_id=who_or_what.id,
-            guild_id=ctx.guild.id,
-        )
+        for w in who_or_what:
+            await self._add_rule(
+                rule=cast(bool, allow_or_deny),
+                cog_or_cmd=cog_or_command,
+                model_id=w.id,
+                guild_id=ctx.guild.id,
+            )
         await ctx.send(_("Rule added."))
 
     @checks.is_owner()
@@ -331,19 +332,17 @@ async def permissions_removeglobalrule(
         self,
         ctx: commands.Context,
         cog_or_command: CogOrCommand,
-        who_or_what: GlobalUniqueObjectFinder,
+        who_or_what: commands.Greedy[GlobalUniqueObjectFinder],
     ):
         """Remove a global rule from a command.
 
         `<cog_or_command>` is the cog or command to remove the rule
         from. This is case sensitive.
 
-        `<who_or_what>` is the user, channel, role or server the rule
-        is for.
+       `<who_or_what>` is one or more users, channels or roles the rule is for.
         """
-        await self._remove_rule(
-            cog_or_cmd=cog_or_command, model_id=who_or_what.id, guild_id=GLOBAL
-        )
+        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."))
 
     @commands.guild_only()
@@ -353,19 +352,19 @@ async def permissions_removeguildrule(
         self,
         ctx: commands.Context,
         cog_or_command: CogOrCommand,
-        *,
-        who_or_what: GuildUniqueObjectFinder,
+        who_or_what: commands.Greedy[GlobalUniqueObjectFinder],
     ):
         """Remove a server rule from a command.
 
         `<cog_or_command>` is the cog or command to remove the rule
         from. This is case sensitive.
 
-        `<who_or_what>` is the user, channel or role the rule is for.
+        `<who_or_what>` is one or more users, channels or roles the rule is for.
         """
-        await self._remove_rule(
-            cog_or_cmd=cog_or_command, model_id=who_or_what.id, guild_id=ctx.guild.id
-        )
+        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
+            )
         await ctx.send(_("Rule removed."))
 
     @commands.guild_only()


Test patch: