CODE TASK: When entering the main channel, the bot creates a new private voice channel with its own rights. If you exit the channel for 10 seconds, the channel is automatically deleted, BUT if you return to this channel during these 10 seconds, the deletion request is canceled and it continues to work until it remains empty for 10 seconds.
MY PROBLEM: I don't understand how to make the undo delete function.
CODE:
import disnake
from disnake.ext import tasks, commands
from asyncio import sleep
import asyncio
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), help_command=None, intents=disnake.Intents.all())
@bot.event
async def on_voice_state_update(member, before, after):
if after.channel and after.channel.id == 'YOUR VOICE CHANNEL ID':
category = after.channel.category
guild = member.guild
channel = await guild.create_voice_channel(name=f' {member.display_name}',category = category)
await channel.set_permissions(member,connect=True,mute_members=True,move_members=True,manage_channels=True)
await member.move_to(channel)
def check(x, y, z):
return len(channel.members) == 0
await bot.wait_for('voice_state_update', check=check)
await sleep(10)
await channel.delete()
Bot.run('TOKEN')
I would appreciate any help