Python 3.x 如何让我的discord bot从我的计算机播放音频文件
我试图让我的机器人在语音聊天中播放音频文件,而不是youtube视频。令人惊讶的是,我在这方面找不到任何有效的帮助Python 3.x 如何让我的discord bot从我的计算机播放音频文件,python-3.x,voice,discord.py-rewrite,Python 3.x,Voice,Discord.py Rewrite,我试图让我的机器人在语音聊天中播放音频文件,而不是youtube视频。令人惊讶的是,我在这方面找不到任何有效的帮助 @client.command() 异步def播放(ctx,*参数): 如果len(args)==0: 等待ctx.send(“然后指定某物”) 其他: #server=ctx.message.server #语音客户端=客户端。语音客户端(服务器) voice\u player=wait ctx.message.author.voice.channel.connect() 如果
@client.command()
异步def播放(ctx,*参数):
如果len(args)==0:
等待ctx.send(“然后指定某物”)
其他:
#server=ctx.message.server
#语音客户端=客户端。语音客户端(服务器)
voice\u player=wait ctx.message.author.voice.channel.connect()
如果args[0]=“chulp”:
打印(“玩小傻瓜”)
source=discord.ffmpegpcaudio(“核心文件\\Sounds\\chulpy.mp3”)
player=voice\u player.play(来源)
player.start()
我总是会遇到这样的错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'start'
你做错了。你必须这样做-
if args[0] == "chulp":
print("Playing chulp")
player = voice_player.create_ffmpeg_player("Core files\\Sounds\\chulpy.mp3")
player.start()
我不确定,但这也能起作用-
if args[0] == "chulp":
print("Playing chulp")
voice_player.play(discord.FFmpegPCMAudio("Core files\\Sounds\\chulpy.mp3"))
我认为您组合了来自两个不同来源的代码
你做错了。你必须这样做-
if args[0] == "chulp":
print("Playing chulp")
player = voice_player.create_ffmpeg_player("Core files\\Sounds\\chulpy.mp3")
player.start()
我不确定,但这也能起作用-
if args[0] == "chulp":
print("Playing chulp")
voice_player.play(discord.FFmpegPCMAudio("Core files\\Sounds\\chulpy.mp3"))
我认为您组合了来自两个不同来源的代码
play
不会返回任何内容,它应该只是开始播放文件。如果删除player.start()
行,会发生什么?它不会更改任何内容play
不会返回任何内容,它应该开始播放文件。如果删除player.start()
行,会发生什么?它不会改变任何东西它不起作用,它甚至不会打印确认它不起作用,它甚至不会打印确认