未找到Discord bot python:Discord.errors.ClientException:ffmpeg

未找到Discord bot python:Discord.errors.ClientException:ffmpeg,python,python-3.x,ffmpeg,discord.py,discord.py-rewrite,Python,Python 3.x,Ffmpeg,Discord.py,Discord.py Rewrite,我正在尝试制作一个在语音频道播放音乐的discord机器人。它连接到语音频道,但不播放任何内容。它还提供了控制台中的一个错误 我在Windows上使用discord.py重写 我的代码: import discord, random, datetime, asyncio, nacl, ffmpeg TOKEN = 'What token' client = discord.Client() @client.event async def on_message(message): if me

我正在尝试制作一个在语音频道播放音乐的discord机器人。它连接到语音频道,但不播放任何内容。它还提供了控制台中的一个错误

我在Windows上使用discord.py重写

我的代码:

import discord, random, datetime, asyncio, nacl, ffmpeg

TOKEN = 'What token'

client = discord.Client()

@client.event
async def on_message(message):
if message.content.lower() == '$play':
    if message.content.lower() == '$play':
        channel = client.get_channel(547155964328149007)
        vc = await channel.connect()
        vc.play(discord.FFmpegPCMAudio('mp3.mp3'), after=lambda e: print('done', e))
        vc.is_playing()
        vc.pause()
        vc.resume()
        vc.stop()

@client.event
async def on_ready():
    print('Logged in as {0.user}'.format(client))

client.run(TOKEN)
错误:

Traceback (most recent call last):
  File "D:\Python35\lib\site-packages\discord\client.py", line 218, in _run_event
    await coro(*args, **kwargs)
  File "discord_bot.py", line 90, in on_message
    vc.play(discord.FFmpegPCMAudio('mp3.mp3'), after=lambda e: print('done', e))
  File "D:\Python35\lib\site-packages\discord\player.py", line 165, in __init__
    raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.
人们似乎在路径环境变量中找不到ffmpeg/avconv时有类似的ish问题,但他们的解决办法是从网站下载ffmpeg并将其放在他们的路径中,但这对我不起作用

此外,当我用Python 3编写机器人程序时,我只能用JavaScript来修复我的问题

以下是我研究中的一些链接:


您可以使用参数executable直接指定FFmpeg可执行文件:

vc = await channel.connect()
vc.play(discord.FFmpegPCMAudio(executable="C:/path/ffmpeg.exe", source="mp3.mp3"))