[Mute] Indicate that a guild mute/unmute is currently being processed. (#4172)

Co-authored-by: fixator10
This commit is contained in:
Dav
2020-08-10 19:19:44 +00:00
committed by jack1142
parent 26122e56a0
commit cf78ea06e2

View File

@@ -3,6 +3,7 @@ from typing import cast, Optional
import discord import discord
from redbot.core import commands, checks, i18n, modlog 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.chat_formatting import format_perms_list
from redbot.core.utils.mod import get_audit_reason, is_allowed_by_hierarchy from redbot.core.utils.mod import get_audit_reason, is_allowed_by_hierarchy
from .abc import MixinMeta from .abc import MixinMeta
@@ -255,11 +256,10 @@ class MuteMixin(MixinMeta):
audit_reason = get_audit_reason(author, reason) audit_reason = get_audit_reason(author, reason)
mute_success = [] mute_success = []
for channel in guild.channels: async with ctx.typing():
success, issue = await self.mute_user(guild, channel, author, user, audit_reason) for channel in guild.channels:
mute_success.append((success, issue)) success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
await asyncio.sleep(0.1) mute_success.append((success, issue))
try:
await modlog.create_case( await modlog.create_case(
self.bot, self.bot,
guild, guild,
@@ -271,9 +271,7 @@ class MuteMixin(MixinMeta):
until=None, until=None,
channel=None, channel=None,
) )
except RuntimeError as e: await ctx.send(_("User has been muted in this server."))
await ctx.send(e)
await ctx.send(_("User has been muted in this server."))
@commands.group() @commands.group()
@commands.guild_only() @commands.guild_only()
@@ -372,11 +370,12 @@ class MuteMixin(MixinMeta):
audit_reason = get_audit_reason(author, reason) audit_reason = get_audit_reason(author, reason)
unmute_success = [] unmute_success = []
for channel in guild.channels: async with ctx.typing():
success, message = await self.unmute_user(guild, channel, author, user, audit_reason) for channel in guild.channels:
unmute_success.append((success, message)) success, message = await self.unmute_user(
await asyncio.sleep(0.1) guild, channel, author, user, audit_reason
try: )
unmute_success.append((success, message))
await modlog.create_case( await modlog.create_case(
self.bot, self.bot,
guild, guild,
@@ -387,9 +386,7 @@ class MuteMixin(MixinMeta):
reason, reason,
until=None, until=None,
) )
except RuntimeError as e: await ctx.send(_("User has been unmuted in this server."))
await ctx.send(e)
await ctx.send(_("User has been unmuted in this server."))
async def mute_user( async def mute_user(
self, self,