'How to mute member in discord voice channel using discord.py
I'm trying to make a bot, that will have a function for Admins to mute members in specific voice channel using slash commands. It completely works, but there is 1 problem - changing permission "speak" only updates after the user reconnected, it sets the permission right after typing the command, but this permission doesn't work untill user reconnects.
Does anyone know how to mute members using permisions changing? So it doesnt show the red muted microphone right next to user's name?Thanks
Here is the code of this function:
@bot.slash_command(name="mute", description="mutes", guild_ids=config.GUILD_IDS, default_permission=False)
@permissions.has_role(config.ROLE_PERMISSION)
async def _mute(ctx: discord.ApplicationContext,
member: Option(discord.Member, description="Member:", required=True),
):
if ctx.author.voice.channel == None:
return
await ctx.author.voice.channel.set_permissions(member, speak=False)
await ctx.respond(f"{member.mention} You have been muted in {ctx.author.voice.channel}!", ephemeral=False)
I tried to change the voice region, so it updates and reconnects, but it didn't work
Solution 1:[1]
I believe you can use await change_voice_state(*, channel, self_mute=False, self_deaf=False) function to do it, link to dock
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bauyrzhan Ospan |
