python - discord.py 播放命令在使用 heroku 时出现 opus 问题
问题描述
所以我的机器人中有一个播放命令
@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 运行机器人
解决方案
discord.opus.load_opus("opus")
不是必需的;您可以安全地删除它。
https://github.com/xrisk/heroku-opus.git buildpack 已经将opus 添加到库路径中。无需进一步配置:)
推荐阅读
- java - 在 OKHTTP 中实现双向间歇性数据通信
- powershell - O365 使用 DeliverToMailboxAndForward 设置邮箱
- xcode - Safari extension builded with Xcode, disappears from Safari after rebuild
- mysql - 如何在同一个mysql安装中链接来自多个mysql数据库的列
- python - 根据输入的类型返回语句(float/int/str)
- api - Katalon Studio - 无法发送测试请求:开始或结束无效
- sql-server - 使用 patindex 从字符串中提取数字的 SQL 查询
- python-2.7 - 在 python 中编码并将其写入 Python 中的 YAML 文件
- c# - 如何覆盖自动创建数据网格列标题?
- sql - 如何导出 Oracle 数据库 11g 的精确副本