Repository: Cog-Creators/Red-DiscordBot

Issue:
Indicate when a server-wide mute is in the process of being applied
# Feature request

#### Select the type of feature you are requesting:

- [ ] Cog
- [x] Command
- [ ] API functionality

#### Describe your requested feature

While the great overhaul for the muting system is being awaited, the current one works fine most of the time, except that it scales particularly poorly to large servers by taking up to two minutes to finish applying each of the channel permission overrides whenever you have an extremely large number of channels.

Because of this, moderators unfamiliar with the command will attempt to use it, see no response from the bot, assume they made a mistake, and then repeatedly try again (perhaps with slight variations to the command). After a minute of trial-and-error, they will throw up their hands in defeat and frustration, and then a minute later, the bot will send five separate confirmations that the user has been muted.

Currently, the easiest solution to this would just be for the bot to send a message whenever a mute command has been successfully entered announcing that the user-to-be-muted is in the process of being muted, and that the moderator should be patient. After it has completed, this message could be edited to the usual "User has been muted in this server".

This sort of feedback would definitely make it more accessible for people unfamiliar with the bot by clearly and immediately communicating the effect of the command to the moderator.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/mod/mutes.py b/redbot/cogs/mod/mutes.py
--- a/redbot/cogs/mod/mutes.py
+++ b/redbot/cogs/mod/mutes.py
@@ -3,6 +3,7 @@
 
 import discord
 from redbot.core import commands, checks, i18n, modlog
+from redbot.core.utils import AsyncIter
 from redbot.core.utils.chat_formatting import format_perms_list
 from redbot.core.utils.mod import get_audit_reason, is_allowed_by_hierarchy
 from .abc import MixinMeta
@@ -254,22 +255,22 @@ async def guild_mute(self, ctx: commands.Context, user: discord.Member, *, reaso
         audit_reason = get_audit_reason(author, reason)
 
         mute_success = []
-        for channel in guild.channels:
-            success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
-            mute_success.append((success, issue))
-            await asyncio.sleep(0.1)
-        await modlog.create_case(
-            self.bot,
-            guild,
-            ctx.message.created_at,
-            "smute",
-            user,
-            author,
-            reason,
-            until=None,
-            channel=None,
-        )
-        await ctx.send(_("User has been muted in this server."))
+        async with ctx.typing():
+            for channel in guild.channels:
+                success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
+                mute_success.append((success, issue))
+            await modlog.create_case(
+                self.bot,
+                guild,
+                ctx.message.created_at,
+                "smute",
+                user,
+                author,
+                reason,
+                until=None,
+                channel=None,
+            )
+            await ctx.send(_("User has been muted in this server."))
 
     @commands.group()
     @commands.guild_only()
@@ -373,14 +374,23 @@ async def unmute_guild(
         audit_reason = get_audit_reason(author, reason)
 
         unmute_success = []
-        for channel in guild.channels:
-            success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
-            unmute_success.append((success, message))
-            await asyncio.sleep(0.1)
-        await modlog.create_case(
-            self.bot, guild, ctx.message.created_at, "sunmute", user, author, reason, until=None,
-        )
-        await ctx.send(_("User has been unmuted in this server."))
+        async with ctx.typing():
+            for channel in guild.channels:
+                success, message = await self.unmute_user(
+                    guild, channel, author, user, audit_reason
+                )
+                unmute_success.append((success, message))
+            await modlog.create_case(
+                self.bot,
+                guild,
+                ctx.message.created_at,
+                "sunmute",
+                user,
+                author,
+                reason,
+                until=None,
+            )
+            await ctx.send(_("User has been unmuted in this server."))
 
     async def mute_user(
         self,


Test patch: