Skip to content

Commit

Permalink
wait and refetch user for unmute / deafen
Browse files Browse the repository at this point in the history
  • Loading branch information
mralext20 committed Sep 19, 2023
1 parent e85bd9f commit 54d6cd7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions alexBot/cogs/voiceCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit 54d6cd7

Please sign in to comment.