Add support for timeouts to Mutes cog (#5604)

Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
TrustyJAID 2024-03-31 18:05:37 -06:00 committed by GitHub
parent e71312ede0
commit 463f0c5e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 436 additions and 345 deletions

View File

@ -0,0 +1,19 @@
from typing import Optional, Dict
import discord
from dataclasses import dataclass
@dataclass
class MuteResponse:
success: bool
reason: Optional[str]
user: discord.Member
@dataclass
class ChannelMuteResponse(MuteResponse):
channel: discord.abc.GuildChannel
old_overs: Optional[Dict[str, bool]]
voice_mute: bool

File diff suppressed because it is too large Load Diff

View File

@ -122,13 +122,13 @@ class VoiceMutes(MixinMeta):
channel = user_voice_state.channel
audit_reason = get_audit_reason(author, reason, shorten=True)
success = await self.channel_mute_user(
result = await self.channel_mute_user(
guild, channel, author, user, until, audit_reason, voice_mute=True
)
if success["success"]:
if "reason" in success and success["reason"]:
issue_list.append((user, success["reason"]))
if result.success:
if result.reason:
issue_list.append((user, result.reason))
else:
success_list.append(user)
await modlog.create_case(
@ -146,9 +146,9 @@ class VoiceMutes(MixinMeta):
user, author, guild, _("Voice mute"), reason, duration
)
async with self.config.member(user).perms_cache() as cache:
cache[channel.id] = success["old_overs"]
cache[channel.id] = result.old_overs
else:
issue_list.append((user, success["reason"]))
issue_list.append((user, result.reason))
if success_list:
msg = _("{users} has been muted in this channel{time}.")
@ -198,13 +198,13 @@ class VoiceMutes(MixinMeta):
channel = user_voice_state.channel
audit_reason = get_audit_reason(author, reason, shorten=True)
success = await self.channel_unmute_user(
result = await self.channel_unmute_user(
guild, channel, author, user, audit_reason, voice_mute=True
)
if success["success"]:
if "reason" in success and success["reason"]:
issue_list.append((user, success["reason"]))
if result.success:
if result.reason:
issue_list.append((user, result.reason))
else:
success_list.append(user)
await modlog.create_case(
@ -222,7 +222,7 @@ class VoiceMutes(MixinMeta):
user, author, guild, _("Voice unmute"), reason
)
else:
issue_list.append((user, success["reason"]))
issue_list.append((user, result.reason))
if success_list:
if channel.id in self._channel_mutes and self._channel_mutes[channel.id]:
await self.config.channel(channel).muted_users.set(self._channel_mutes[channel.id])