я создаю своего музыкального бота для дискорда. Сейчас моя задача сделать так, чтобы мой бот мог просто проигрывать видео из YouTube в голосовом канале, где находится автор сообщения. Чтобы бот проиграл видео надо использовать префикс:ссылка_на_видео, однако у меня выводится ошибка, но бот из голосового канала не выходит.
Я пробывал исправить эту ошибку - обновить модуль ffmpeg, что не дало мне результатов.
Ошибка: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OSError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
from discord.ext import commands
import pafy
import asyncio
import ffmpeg
settings = {
'token': 'скрыт',
'bot': 'Zyni',
'id': скрыт,
'prefix': '!'
}
intents = discord.Intents.all()
intents.voice_states = True
intents.members = True
bot = commands.Bot(command_prefix=settings['prefix'], intents=intents)
@bot.command()
async def play(ctx, url: str):
if not ctx.author.voice:
return await ctx.send("Ты не подключен к голосовому каналу")
else:
channel = ctx.author.voice.channel
voice_client = await channel.connect()
video = pafy.new(url)
audio = video.getbestaudio()
audio_url = audio.url
print(f"Playing {audio.title}")
player = voice_client.play(discord.FFmpegPCMAudio(audio_url))
while not player.is_done():
await asyncio.sleep(1)
await voice_client.disconnect()
bot.run(settings['token'])