[英]How do I troubleshoot this error: OSError: [Errno 9] Bad file descriptor
[英]OSError: [Errno 9] Bad file descriptor discord bot
我正在使用 discord.py API 開發 discord 機器人。 我正在嘗試讓機器人加入語音頻道並播放同一目錄中的 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()
問題是你給音頻文件的路徑是錯誤的。 您必須使用單個反斜杠為其提供文件的整個路徑
voice.play(discord.FFmpegPCMAudio("C:\whereever\the\file\is\BravoSix.mp3"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.