Python 音乐不和谐机器人
我出错了,有人能帮我吗?它告诉我必须安装FFmpeg或FFrobe。从exc引发CommandInvokeError(exc)Python 音乐不和谐机器人,python,discord,Python,Discord,我出错了,有人能帮我吗?它告诉我必须安装FFmpeg或FFrobe。从exc引发CommandInvokeError(exc) discord.ext.commands.errors.CommandInvokeError:命令引发异常:DownloadError:错误:未找到ffprobe/avprobe和ffmpeg/avconv。请安装一个。这是否回答了您的问题?没有,但我还在努力 import discord from discord.ext import commands import
discord.ext.commands.errors.CommandInvokeError:命令引发异常:DownloadError:错误:未找到ffprobe/avprobe和ffmpeg/avconv。请安装一个。这是否回答了您的问题?没有,但我还在努力
import discord
from discord.ext import commands
import youtube_dl
import ffmpeg
import os
client = commands.Bot(command_prefix="!")
@client.command()
async def play(ctx, url: str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")
return
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='General')
await voiceChannel.connect()
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio("song.mp3"))
@client.command()
async def leave(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_connected():
await voice.disconnect()
else:
await ctx.send("The bot is not connected to a voice channel.")
@client.command()
async def pause(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_playing():
voice.pause()
else:
await ctx.send("Currently no audio is playing.")
@client.command()
async def resume(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_paused():
voice.resume()
else:
await ctx.send("The audio is not paused.")
@client.command()
async def stop(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
voice.stop()
client.run(TOKEN)