Этот вопрос закрыт для ответов, так как повторяет вопрос Kак работать с библиотекой ffmpeg-python?
@ninja_haro

Сможете помочь с ошибкой при создании музыкального дискорд бота?

Недавно решил спросить у чатагпт написать код для муз. бота, так как совсем не силён в программировании. Подправил как смог, но в итоге выдаёт такую ошибку после команды play. Вроде все библиотеки установил, ffmpeg в том числе, но он его не видит, почему-то..
Traceback
2023-08-04 14:58:32 ERROR discord.ext.commands.bot Ignoring exception in command play
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\programmmmmm\rw3f\myzuka\muzika.py", line 39, in play
voice_client = await voice_channel.connect()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py", line 290, in __init__
super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py", line 166, in __init__
self._process = self._spawn_process(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py", line 183, 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\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.

код
// сам код
import discord
from discord import FFmpegPCMAudio
from discord.ext import commands
from discord.utils import get

intents = discord.Intents.default()
intents.typing = False
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')

@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
voice_client = get(bot.voice_clients, guild=ctx.guild)

if voice_client and voice_client.is_connected():
await voice_client.move_to(channel)
else:
voice_client = await channel.connect()

await ctx.send(f"Joined voice channel: {channel}")

@bot.command()
async def leave(ctx):
voice_client = discord.utils.get(bot.voice_clients, guild=ctx.guild)
if voice_client.is_connected():
await voice_client.disconnect()
await ctx.send('Left the voice channel!')

@bot.command()
async def play(ctx, url):
voice_channel = ctx.author.voice.channel
voice_client = await voice_channel.connect()
audio_source = FFmpegPCMAudio(url)
voice_client.play(audio_source)

if not voice_client.is_playing():
voice_client.play(discord.FFmpegPCMAudio(url))
await ctx.send('Now Im playing: ' + url)
else:
await ctx.send('I am already playing music!')

@bot.command()
async def stop(ctx):
voice_client = get(bot.voice_clients, guild=ctx.guild)

if voice_client.is_playing():
voice_client.stop()
await ctx.send('Music stopped.')
else:
await ctx.send('There is no music playing.')

bot.run('token')
  • Вопрос задан
  • 45 просмотров
Ваш ответ на вопрос

Вопрос закрыт для ответов и комментариев

Потому что уже есть похожий вопрос.
Похожие вопросы