【问题标题】:OSError: [Errno 9] Bad file descriptor discord botOSError:[Errno 9] 错误的文件描述符不和谐机器人
【发布时间】:2020-11-28 23:28:48
【问题描述】:

我正在使用 discord.py API 开发一个不和谐机器人。我正在尝试让机器人加入语音频道并播放同一目录中的 mp3 文件。它加入语音频道,但在播放任何内容之前会在标题中打印错误。我想知道是什么导致了这个错误。相关代码如下:

@client.command()
async def playClip(ctx):
    global voice
    channel=ctx.message.author.voice.channel
    voice= get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice= await channel.connect()

    voice.play(discord.FFmpegPCMAudio("BravoSix.mp3"))
    print("test")
    await voice.disconnect()

【问题讨论】:

    标签: python-3.x ffmpeg discord.py discord.py-rewrite


    【解决方案1】:

    问题是你给音频文件的路径是错误的。 您必须使用单个反斜杠为其提供文件的完整路径

    voice.play(discord.FFmpegPCMAudio("C:\whereever\the\file\is\BravoSix.mp3"))
    

    【讨论】:

    • 我都试过了,第一个给了我同样的错误。第二个给我一个错误说“C:\\filepath\\file”协议未找到,你的意思是文件:“C:\\Exact Same Filepath”
    • 您实际上可能不必使用双反斜杠,而是使用单反斜杠
    猜你喜欢
    • 2020-05-20
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    • 2020-08-28
    相关资源
    最近更新 更多