async def try_edit(self, member: Member, vc: Optional[VoiceChannel], mute: bool, deafen: bool): if not hasattr(member, "guild"): member = self.manager.guild.get_member(member.id) logger.debug(f"try edit {member.display_name} @ {member.guild.name}" f" -> vc: {vc and vc.name} mute: {mute} deafen: {deafen}") target_voice = VoiceState(data=dict(mute=mute, deafen=deafen), channel=vc) voice_state: VoiceState = member.voice if not voice_state or not voice_state.channel: return if voice_state == target_voice: return await asyncio.create_task( member.edit(voice_channel=target_voice.channel, mute=target_voice.mute, deafen=target_voice.deaf))
async def on_member_join(self, member: Member) -> None: """Reapply active superstar infractions for returning members.""" active_superstarifies = await self.bot.api_client.get( "bot/infractions", params={ "active": "true", "type": "superstar", "user__id": member.id }) if active_superstarifies: infraction = active_superstarifies[0] action = member.edit( nick=self.get_nick(infraction["id"], member.id), reason= f"Superstarified member tried to escape the prison: {infraction['id']}" ) await self.reapply_infraction(infraction, action)