【发布时间】:2021-05-04 07:53:41
【问题描述】:
我制作了这个可以工作的音乐机器人代码,它加入了 vc 并播放歌曲。但是当它发出声音时,它不会播放另一个,我需要断开他的连接。即使他加入,我也希望他播放下一首歌。怎么做?
代码(我想要的部分):
@bot.command()
async def hraj(ctx, url):
if not ctx.message.author.voice:
await ctx.send("Musíš být ve voicu ty pepego!")
return
else:
channel = ctx.message.author.voice.channel
await channel.connect()
server = ctx.message.guild
voice_channel = server.voice_client
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=bot.loop)
voice_channel.play(player, after=lambda e: print("Error. %s" %e if e else None))
e = discord.Embed(title="Právě hraje:", description=f"[{player.title}]({url})", color=0x0091ff)
e.set_footer(text="Lets go jdem vibovat <333")
await ctx.send(embed=e)
【问题讨论】: