M
M
muri_top2021-10-13 15:53:05
Python
muri_top, 2021-10-13 15:53:05

Discord.py does not remove the voice channel. What is the problem?

I’m studying discord py and making a private room bot.
As planned, the bot, when entering a certain channel, creates a room in a certain category and throws a person, and deletes the room on exit, but nothing happens when exiting.
I’m still weak in this topic, so I hope for adequate answers) Thanks

async def on_voice_state_update(member, before, after):
    if after.channel and after.channel.name=="Основной":
        print(f"Пользователь {member.name} зашел на {after.channel.name}")
        try:
            guild = bot.get_guild(797156509170925569) 
            category2 =  guild.get_channel(897819716394033202)
            channel2= await guild.create_voice_channel(f"Комната: {member.name}", overwrites=None, category=category2,
                                             reason=None)

        except Exception as errors:
            print(f"Bot Error: {errors}")
        await member.move_to(channel2)
        
        if len(channel2.members) == 0:

            channel2.delete()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2021-10-13
@muri_top

Probably because VoiceChannel.delete(...)- asynchronous method
await channel2.delete()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question