Как создать приватные голосовые каналы.Помогите написал код

NeriOff

Новичок
Пользователь
Дек 16, 2020
4
1
3
Написал код
@client.event
async def on_voice_state_update(member,before,after):
if after.channel.id == 789090452162609212:
for guild in Bot.guilds:
maincategory = discord.utils.get(guild.categories, id=789090413033291787)
channel2 = await guild.create_voice_channel(name=f'Приватка {member.display_name}',category = maincategory)
await channel2.set_permissions(member,connect=True,mute_members=True,move_members=True,manage_channels=True)
await member.move_to(channel2)
def check(x,y,z):
return len(channel2.members) == 0
await Bot.wait_for('voice_state_update',check=check)

В итоге при заходе в войс ничего не происходит а в консоли пишет


Ignoring exception in on_voice_state_update
Traceback (most recent call last):
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 34, in on_voice_state_update
for guild in Bot.guilds:
NameError: name 'Bot' is not defined
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 33, in on_voice_state_update
if after.channel.id == 789090452162609212:
AttributeError: 'NoneType' object has no attribute 'id'
 

Форум IT Специалистов