【问题标题】:discord.py play command has problems with opus while using herokudiscord.py 播放命令在使用 heroku 时出现 opus 问题
【发布时间】: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


【解决方案1】:

discord.opus.load_opus("opus") 不是必需的;您可以安全地删除它。

https://github.com/xrisk/heroku-opus.git buildpack 已经将 opus 添加到库路径。无需进一步配置:)

【讨论】:

  • 嗯,你有什么不和或什么,如果你愿意的话,可以更容易地帮助我。
猜你喜欢
  • 2019-04-04
  • 2021-07-14
  • 2021-10-21
  • 2015-08-08
  • 1970-01-01
  • 2021-02-16
  • 1970-01-01
  • 1970-01-01
  • 2019-03-16
相关资源
最近更新 更多