From 54d6cd7ece23845cd1f2649cc77c88218c758e5d Mon Sep 17 00:00:00 2001 From: Alexander Terry Date: Tue, 19 Sep 2023 04:20:38 -0800 Subject: [PATCH] wait and refetch user for unmute / deafen --- alexBot/cogs/voiceCommands.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/alexBot/cogs/voiceCommands.py b/alexBot/cogs/voiceCommands.py index ad1913a..898db4a 100644 --- a/alexBot/cogs/voiceCommands.py +++ b/alexBot/cogs/voiceCommands.py @@ -161,7 +161,9 @@ async def voice_theatre(self, interaction: discord.Interaction, name: Optional[s pass @Cog.listener() - async def on_voice_state_update(self, member, before: Optional[VoiceState], after: Optional[VoiceState]): + async def on_voice_state_update( + self, member: discord.Member, before: Optional[VoiceState], after: Optional[VoiceState] + ): if before.channel.id in self.current_thatars: if len(before.channel.members) == 0: await before.channel.delete(reason="no one left") @@ -182,7 +184,9 @@ async def on_voice_state_update(self, member, before: Optional[VoiceState], afte if uc.unMuteAndDeafenOnJoin: # user wants it if before.channel is None and after.channel is not None: # initial join, we can just blindly unmute and undeafen - await member.edit(mute=False, deafen=False) + # but first we need to wait a moment for the user to be actually connected and accept the mute/deafen + await asyncio.sleep(2) + await (await guild.fetch_member(member.id)).edit(mute=False, deafen=False) @app_commands.guild_only() @app_commands.checks.bot_has_permissions(move_members=True)