Fix unmuting when a mod isn't a mod anymore. (#6411)

Co-authored-by: TrustyJAID <TrustyJAID@gmail.com>
This commit is contained in:
Kowlin 2024-08-04 23:01:34 +02:00 committed by GitHub
parent 7eb26da647
commit 2d47d75919
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -329,7 +329,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
del muted_users[str(data["member"])] del muted_users[str(data["member"])]
del self._server_mutes[guild.id][data["member"]] del self._server_mutes[guild.id][data["member"]]
return return
result = await self.unmute_user(guild, author, member, _("Automatic unmute")) result = await self.unmute_user(guild, None, member, _("Automatic unmute"))
async with self.config.guild(guild).muted_users() as muted_users: async with self.config.guild(guild).muted_users() as muted_users:
if str(member.id) in muted_users: if str(member.id) in muted_users:
del muted_users[str(member.id)] del muted_users[str(member.id)]
@ -507,7 +507,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
del self._channel_mutes[channel.id][data["member"]] del self._channel_mutes[channel.id][data["member"]]
return None return None
result = await self.channel_unmute_user( result = await self.channel_unmute_user(
channel.guild, channel, author, member, _("Automatic unmute") channel.guild, channel, None, member, _("Automatic unmute")
) )
async with self.config.channel(channel).muted_users() as muted_users: async with self.config.channel(channel).muted_users() as muted_users:
if str(member.id) in muted_users: if str(member.id) in muted_users:
@ -1750,7 +1750,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
async def unmute_user( async def unmute_user(
self, self,
guild: discord.Guild, guild: discord.Guild,
author: discord.Member, author: Optional[discord.Member],
user: discord.Member, user: discord.Member,
reason: Optional[str] = None, reason: Optional[str] = None,
) -> MuteResponse: ) -> MuteResponse:
@ -1760,7 +1760,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
ret: MuteResponse = MuteResponse(success=False, reason=None, user=user) ret: MuteResponse = MuteResponse(success=False, reason=None, user=user)
mute_role_id = await self.config.guild(guild).mute_role() mute_role_id = await self.config.guild(guild).mute_role()
if not await self.is_allowed_by_hierarchy(guild, author, user): if author is not None and not await self.is_allowed_by_hierarchy(guild, author, user):
ret.reason = _(MUTE_UNMUTE_ISSUES["hierarchy_problem"]) ret.reason = _(MUTE_UNMUTE_ISSUES["hierarchy_problem"])
return ret return ret
@ -1926,7 +1926,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
self, self,
guild: discord.Guild, guild: discord.Guild,
channel: discord.abc.GuildChannel, channel: discord.abc.GuildChannel,
author: discord.Member, author: Optional[discord.Member],
user: discord.Member, user: discord.Member,
reason: Optional[str] = None, reason: Optional[str] = None,
*, *,
@ -1963,7 +1963,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if channel.permissions_for(guild.me).move_members: if channel.permissions_for(guild.me).move_members:
move_channel = True move_channel = True
if not await self.is_allowed_by_hierarchy(guild, author, user): if author is not None and not await self.is_allowed_by_hierarchy(guild, author, user):
ret.reason = _(MUTE_UNMUTE_ISSUES["hierarchy_problem"]) ret.reason = _(MUTE_UNMUTE_ISSUES["hierarchy_problem"])
return ret return ret