不和谐机器人python

不和谐机器人python,python,discord,discord.py,Python,Discord,Discord.py,所以我想在我的discord语音频道播放本地文件,现在它加入了语音频道,但它什么都不播放。代码如下: if message.content.startswith(“$Hest”): 其中=message.content.split(“”[1] channel=get(message.guild.channels,name=where) voicechannel=等待频道。连接() voicechannel.play(discord.FFempegPCMAudio(可执行文件='D:/ffmpeg

所以我想在我的discord语音频道播放本地文件,现在它加入了语音频道,但它什么都不播放。代码如下:

if message.content.startswith(“$Hest”):
其中=message.content.split(“”[1]
channel=get(message.guild.channels,name=where)
voicechannel=等待频道。连接()
voicechannel.play(discord.FFempegPCMAudio(可执行文件='D:/ffmpeg/ffmpeg/bin/ffplay.exe',source='D:/ffmpeg/Horse.mp3'))
这是我尝试这样做时的输出

Traceback (most recent call last):
  File "F:\Apanda\CustomMultiPyBot\venv\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "F:/Apanda/CustomMultiPyBot/main.py", line 41, in on_message
    voicechannel.play(discord.FFempegPCMAudio(executable='D:/ffmpeg/ffmpeg/bin/ffplay.exe', source='D:/ffmpeg/Horse.mp3'))
AttributeError: module 'discord' has no attribute 'FFempegPCMAudio'

这个问题只是因为您试图在类实际运行时使用
discord.FFempegPCMAudio

因此,要更正您的代码:

if message.content.startswith(“$Hest”):
其中=message.content.split(“”[1]
channel=get(message.guild.channels,name=where)
voicechannel=等待频道。连接()
voicechannel.play(
discord.ffmpegpcaudio(
'D:/ffmpeg/Horse.mp3',
可执行文件='D:/ffmpeg/ffmpeg/bin/ffplay.exe'
)
)
如果您想重新构造它以使用,您的代码将如下所示:

导入不一致
从discord.ext导入命令
bot=commands.bot(command_prefix=“$”)
@bot.command(name=“Hest”)
异步定义(ctx,其中):
channel=discord.utils.get(ctx.guild.channels,name=where)
voicechannel=等待频道。连接()
voicechannel.play(
discord.ffmpegpcaudio(
'D:/ffmpeg/Horse.mp3',
可执行文件='D:/ffmpeg/ffmpeg/bin/ffplay.exe'
)
)
bot.run(“”)

请注意:我建议使用而不是使用
message.content.startswith()
,因为这通常是更好的练习。谢谢你的建议:)哇,谢谢你,我在这一点上真的是目瞪口呆,非常感谢!