【发布时间】:2020-12-31 00:17:34
【问题描述】:
所以我的机器人中有一个播放命令
@client.command()
async def play(ctx, url):
YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist':'True'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if not voice.is_playing():
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
URL = info['formats'][0]['url']
voice.play(discord.FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
voice.is_playing()
else:
await ctx.send("Already playing song")
return
和开头的 discord.opus.load_opus("opus") 行。当我尝试运行命令时,我收到此错误OSError: opus: cannot read file data: Is a directory
PS我正在使用 Heroku 24/7 运行机器人
【问题讨论】:
-
安装 opus buildpack。
-
啊抱歉我忘了说我已经安装了这个buildpack
-
尝试在没有 load_opus 行的情况下运行它,我认为没有必要。
-
成功了,非常感谢。我没想到解决方案这么简单:D
-
顺便说一句,我写了您链接的存储库;)将不胜感激。
标签: python discord.py