mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Add support for timeouts to Mutes cog (#5604)
Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
parent
e71312ede0
commit
463f0c5e6d
19
redbot/cogs/mutes/models.py
Normal file
19
redbot/cogs/mutes/models.py
Normal 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
@ -122,13 +122,13 @@ class VoiceMutes(MixinMeta):
|
|||||||
channel = user_voice_state.channel
|
channel = user_voice_state.channel
|
||||||
audit_reason = get_audit_reason(author, reason, shorten=True)
|
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
|
guild, channel, author, user, until, audit_reason, voice_mute=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if success["success"]:
|
if result.success:
|
||||||
if "reason" in success and success["reason"]:
|
if result.reason:
|
||||||
issue_list.append((user, success["reason"]))
|
issue_list.append((user, result.reason))
|
||||||
else:
|
else:
|
||||||
success_list.append(user)
|
success_list.append(user)
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
@ -146,9 +146,9 @@ class VoiceMutes(MixinMeta):
|
|||||||
user, author, guild, _("Voice mute"), reason, duration
|
user, author, guild, _("Voice mute"), reason, duration
|
||||||
)
|
)
|
||||||
async with self.config.member(user).perms_cache() as cache:
|
async with self.config.member(user).perms_cache() as cache:
|
||||||
cache[channel.id] = success["old_overs"]
|
cache[channel.id] = result.old_overs
|
||||||
else:
|
else:
|
||||||
issue_list.append((user, success["reason"]))
|
issue_list.append((user, result.reason))
|
||||||
|
|
||||||
if success_list:
|
if success_list:
|
||||||
msg = _("{users} has been muted in this channel{time}.")
|
msg = _("{users} has been muted in this channel{time}.")
|
||||||
@ -198,13 +198,13 @@ class VoiceMutes(MixinMeta):
|
|||||||
channel = user_voice_state.channel
|
channel = user_voice_state.channel
|
||||||
audit_reason = get_audit_reason(author, reason, shorten=True)
|
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
|
guild, channel, author, user, audit_reason, voice_mute=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if success["success"]:
|
if result.success:
|
||||||
if "reason" in success and success["reason"]:
|
if result.reason:
|
||||||
issue_list.append((user, success["reason"]))
|
issue_list.append((user, result.reason))
|
||||||
else:
|
else:
|
||||||
success_list.append(user)
|
success_list.append(user)
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
@ -222,7 +222,7 @@ class VoiceMutes(MixinMeta):
|
|||||||
user, author, guild, _("Voice unmute"), reason
|
user, author, guild, _("Voice unmute"), reason
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
issue_list.append((user, success["reason"]))
|
issue_list.append((user, result.reason))
|
||||||
if success_list:
|
if success_list:
|
||||||
if channel.id in self._channel_mutes and self._channel_mutes[channel.id]:
|
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])
|
await self.config.channel(channel).muted_users.set(self._channel_mutes[channel.id])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user