Answer the question
In order to leave comments, you need to log in
How to restrict access to the channel to users with the same nicknames?
There is a function that automatically distributes roles to those who are on the list, using the role, users get access to a private voice channel
@bot.event
async def on_voice_state_update(member, before, after):
clients = ['Dr','1','2']
if not before.channel and after.channel:
role = discord.utils.get(member.guild.roles, name="Клиент")
if member.display_name in clients:
await member.add_roles(role)
elif before.channel and not after.channel:
role = discord.utils.get(member.guild.roles, name="Клиент")
await member.remove_roles(role)
Answer the question
In order to leave comments, you need to log in
discord.Member has an attributeid
.
@bot.event
async def on_voice_state_update(member, before, after):
clients = [969338428647912064, 424184503818564866, 424184503818564866]
role = bot.get_role(240688302893711904)
if not before.channel and after.channel:
if member.id in clients:
await member.add_roles(role)
elif before.channel and not after.channel:
await member.remove_roles(role)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question