Запуск песни музыкального дискорд бота

пытаюсь запускать в дискорде песню, которая скачана на устройстве

global vc

try:
    voice_channel = ctx.message.author.voice.channel
    vc = await voice_channel.connect()
except:
    print('Уже подключен или не удалось подключиться')
    return 0
vc = await voice_channel.connect()
if vc.is_playing():
    await ctx.send(f'{ctx.message.author.mention}, музыка уже проигрывается.')

else:
    vc.play(discord.FFmpegPCMAudio(executable="C:\\ffmpeg\\bin\\ffmpeg.exe", source="333.mp3", **FFMPEG_OPTIONS))

    while vc.is_playing():
        await sleep(1)
    if not vc.is_paused():
        await vc.disconnect()
await ctx.reply(a)

В любом случае я оказываюсь в except: "Уже подключен или не удалось подключиться". В чем проблема? upd: пофиксил часть кода, но теперь проблема в том, что бот заходит и моментально выходит из войса, как фиксить?

async def music(ctx,*args):
a = send_search_request_and_print_result(args)
global vc
try:
    voice_channel = ctx.author.voice.channel
    vc = await voice_channel.connect()
except Exception as e:
    print('Уже подключен или не удалось подключиться')
    return 0
if vc.is_playing():
    await ctx.send(f'{ctx.message.author.mention}, музыка уже проигрывается.')

else:
    vc.play(discord.FFmpegPCMAudio(executable = "C:\\ffmpeg\\bin\\ffmpeg.exe", source="333.mp3", **FFMPEG_OPTIONS))

    while vc.is_playing():
        await sleep(1)
    if not vc.is_paused():
        await vc.disconnect()
await ctx.reply(a)

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