Discord 音乐机器人
Discord Music Bot
我正在创建一个播放音乐的 discord 机器人。成功加入频道,但搜索音乐时returns出错。这是我的代码:
@client.command(pass_context=True)
async def play(ctx, url):
server = ctx.message.server
await client.join_voice_channel(ctx.message.author.voice.voice_channel)
voice_client = client.voice_client_in(server)
player = await voice_client.create_ytdl_player(url)
players[server.id] = player
player.start()
其中returns这个错误:
[youtube] vRquPxdHNGE: Downloading webpage
[youtube] vRquPxdHNGE: Downloading video info webpage
Ignoring exception in command play
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 431, in create_ffmpeg_player
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
stderr=stderr)
File
"C:\Users\user\AppData\Local\Programs\Python\Python36\lib\subprocess.py",
line 709, in __init__
restore_signals, start_new_session)
File
"C:\Users\user\AppData\Local\Programs\Python\Python36\lib\subprocess.py",
line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "F:\.Computer Science\Python\bot.py", line 49, in play
player = await voice_client.create_ytdl_player(url)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 541, in create_ytdl_player
player = self.create_ffmpeg_player(download_url, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 434, in create_ffmpeg_player
raise ClientException('ffmpeg/avconv was not found in your PATH
environment variable') from e
discord.errors.ClientException: ffmpeg/avconv was not found in your PATH
environment variable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception:
ClientException: ffmpeg/avconv was not found in your PATH environment
variable
有谁知道为什么会这样或者我该如何解决?我正在使用 Python 3.6.7 和最新的 Discord 模块。
也许您的解决方案可以是 here,如果您使用的是 virtualenv,请检查您的 PATH 是否也存在。
我正在创建一个播放音乐的 discord 机器人。成功加入频道,但搜索音乐时returns出错。这是我的代码:
@client.command(pass_context=True)
async def play(ctx, url):
server = ctx.message.server
await client.join_voice_channel(ctx.message.author.voice.voice_channel)
voice_client = client.voice_client_in(server)
player = await voice_client.create_ytdl_player(url)
players[server.id] = player
player.start()
其中returns这个错误:
[youtube] vRquPxdHNGE: Downloading webpage
[youtube] vRquPxdHNGE: Downloading video info webpage
Ignoring exception in command play
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 431, in create_ffmpeg_player
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
stderr=stderr)
File
"C:\Users\user\AppData\Local\Programs\Python\Python36\lib\subprocess.py",
line 709, in __init__
restore_signals, start_new_session)
File
"C:\Users\user\AppData\Local\Programs\Python\Python36\lib\subprocess.py",
line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "F:\.Computer Science\Python\bot.py", line 49, in play
player = await voice_client.create_ytdl_player(url)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 541, in create_ytdl_player
player = self.create_ffmpeg_player(download_url, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\voice_client.py", line 434, in create_ffmpeg_player
raise ClientException('ffmpeg/avconv was not found in your PATH
environment variable') from e
discord.errors.ClientException: ffmpeg/avconv was not found in your PATH
environment variable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-
packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception:
ClientException: ffmpeg/avconv was not found in your PATH environment
variable
有谁知道为什么会这样或者我该如何解决?我正在使用 Python 3.6.7 和最新的 Discord 模块。
也许您的解决方案可以是 here,如果您使用的是 virtualenv,请检查您的 PATH 是否也存在。