Отключение музыкального бота от канала через время

Как сделать чтобы бот сам отключался от голосового канала после 3 минут без воспроизведения музыки? Пока что есть такой код:

@bot.command(name='play')
async def play(ctx, arg=None):
    global vc
    global voice_channel
    if arg==None:
        await  ctx.send('Укажите ссылку')
        return
    if ctx.message.author.voice==None:
        await ctx.send('Вы не в голосовом канале')
    else:
        try:
            print(voice_channel.id)
        except:
            voice_channel = ctx.message.author.voice.channel
            vc = await voice_channel.connect()

        if not vc.is_playing() and ctx.message.author.voice.channel.id!=voice_channel.id:
            await vc.disconnect()
            try:
                voice_channel = ctx.message.author.voice.channel
                vc = await voice_channel.connect()
            except:
                pass
        elif ctx.message.author.voice.channel.id!=voice_channel.id:
            await ctx.send('Музыка играет в другом канале')

        if not vc.is_playing():
            with YoutubeDL(YDL_OPTIONS) as ydl:
                info = ydl.extract_info(arg, download=False)
            URL = info['formats'][0]['url']
            vc.play(discord.FFmpegPCMAudio(source=URL, **FFMPEG_OPTIONS))

Ответы (0 шт):