所以在更新 Discord.py 版本后,我的机器人停止工作。似乎在遇到这行代码之后就停止了等待ctx.author.voice.channel.connect()。下面是一段代码
@commands.command()
async def play(self, ctx, *, song=None):
playlist = False
if song is None:
return await ctx.send('You must include a song to play')
if ctx.author.voice is None:
await ctx.send("You are not connected to a voice channel!")
return
if ctx.voice_client is None:
await ctx.author.voice.channel.connect(reconnect=True)
print(ctx.author.voice.channel.id)
if song[0:4] != "http" and song[0:3] != "www":
print("seaking")
await ctx.send('Searching for a song, it will probably take a few seconds')
result = await self.search_song(1, song, get_url=True)
if result is None:
return await ctx.send("Sorry, I could not find the given song")
song = result
url = youtube_dl.YoutubeDL(self.ydl_opts).extract_info(song, download=False)
"""'If' below is for checking whether it`s playlist or not and if it is, it will store this information for later use"""
if 'entries' in url:
playlist = True
(我尝试过降级版本,但这没有任何改变)。我尝试过重新安装软件包并更改意图。但似乎没有任何作用。提前感谢帮助
很可能是在更新discord.py时,您忘记包含语音所需的PyNaCl。尝试重新安装带有 [voice] 后缀的discord.py。
pip install -U discord.py[voice]