Для исправления уже перепробовал все, не знаю в чем причина
Ignoring exception in command play:
Traceback (most recent call last):
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\heineken\Desktop\wisp.bot\import discord.py", line 115, in play
voice.play(discord.FFmpegPCMAudio('song.mp3'))
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 225, in __init__
super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 138, in __init__
self._process = self._spawn_process(args, **kwargs)
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 147, in _spawn_process
raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\heineken\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.
@bot.command()
async def play(ctx, *, command = None):
server, server_id, name_channel = None, None, None
'''Воспроизводит музыку'''
author = ctx.author
if command == None:
server = ctx.guild
name_channel = ctx.author.voice.channel.name
voice_channel = discord.utils.get(server.voice_channels, name = name_channel)
params = command.split(' ')
if len(params) == 1:
sourse = params[0]
server = ctx.guild
name_channel = author.voice.channel.name
voice_channel = discord.utils.get(server.voice_channels, name = name_channel)
print('params 1')
elif len(params) == 3:
server_id = params[0]
voice_id = params[1]
sourse = params[2]
print('params 3')
try:
server_id = int(server_id)
voice_id = int(voice_id)
except:
await ctx.channel.send(f'{author.mention}, id сервера или войса должно быть целочисленними ')
return
print('params 3')
server = bot.get_guild(server_id)
voice_channel = discord.utils.get(server.voice_channels, id = voice_id)
else:
await ctx.channel.send(f'{author.mention}, команда некорректна')
return
voice = discord.utils.get(bot.voice_clients, guild = server)
if voice is None:
await voice_channel.connect()
voice = discord.utils.get(bot.voice_clients, guild = server)
if sourse == None:
pass
elif sourse.startswith('http'):
if not check_domains(sourse):
await ctx.channel.send(f'{author.mention}, ссылка не корректа не с ютба')
return
song_there = os.path.isfile('song.mp3')
try:
if song_there:
os.remove('song.mp3')
except PermissionError:
await ctx.channel.send('Недостаточно прав для удаления файла')
return
ydl_options = {
'format': 'bestaudio/best',
'postprocess': [
{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}
]
}
with youtube_dl.YoutubeDL(ydl_options) as ydl:
ydl.download([sourse])
for file in os.listdir('./'):
if file.endswith('.mp3'):
os.rename(file, 'song.mp3')
voice.play(discord.FFmpegPCMAudio('song.mp3'))
else:
voice.play(discord.FFmpegPCMAudio(sourse))