【发布时间】:2021-11-22 03:36:24
【问题描述】:
async def playnext(self, message):
if self.songQ != []:
self.nuses = self.nuses + 1
message.voice_client.play(discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(pafy.new(self.songQ[0]).getbestaudio().url)), after=lambda error: self.removeplay(message))
else:
await message.channel.send("Queue is empty")
我正在尝试使用消息创建 .playnext() 方法,但我不知道如何形成第 4 行的语法,因为根据我得到的错误,message.voice_client 没有方法 .play()。
我见过人们使用discord.ctx 这样做:
ctx.voice_client.play(discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(pafy.new(self.songQ[0]).getbestaudio().url)), after=lambda error: self.removeplay(message))
但是我的整个机器人是建立在on_message() 函数上的,我不想在这个项目中使用不和谐的命令。
【问题讨论】:
-
你能发布确切的错误信息吗?因为Discord.py的官方文档说VoiceClient有play方法。
标签: python python-3.x discord discord.py bots