OSError: [Errno 9] Bad file descriptor discord bot
OSError: [Errno 9] Bad file descriptor discord bot
我正在使用 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()
问题是你给音频文件的路径有误。
您必须使用单个反斜杠
为其提供文件的完整路径
voice.play(discord.FFmpegPCMAudio("C:\whereever\the\file\is\BravoSix.mp3"))
我正在使用 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()
问题是你给音频文件的路径有误。 您必须使用单个反斜杠
为其提供文件的完整路径voice.play(discord.FFmpegPCMAudio("C:\whereever\the\file\is\BravoSix.mp3"))