【发布时间】:2023-03-18 05:14:02
【问题描述】:
我正在尝试让我的机器人在语音聊天中播放音频文件,而不是 youtube 视频。令人惊讶的是,我真的找不到任何有用的帮助。
@client.command()
async def play(ctx, *args):
if len(args) == 0:
await ctx.send("Specify something then")
else:
#server = ctx.message.server
#voice_client = client.voice_client_in(server)
voice_player = await ctx.message.author.voice.channel.connect()
if args[0] == "chulp":
print("Playing chulp")
source = discord.FFmpegPCMAudio("Core files\\Sounds\\chulpy.mp3")
player = voice_player.play(source)
player.start()
我总是收到这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'start'
【问题讨论】:
-
play不返回任何内容,它应该只是开始播放文件。如果删除player.start()行,会发生什么? -
它不会改变任何东西
标签: python-3.x voice discord.py-rewrite