我在 python 中做了这个,但它不起作用。机器人可以加入频道和一切,但它不播放音乐。在 https://github.com/RK-Coding/Videos/blob/master/rkcodingmusic.py 中找到此代码以尝试查看是否还有其他方法有效,但仍然无效。
@client.command(name='play', help='This command plays songs')
async def play(ctx):
global queue
server = ctx.message.guild
voice_channel = server.voice_client
async with ctx.typing():
player = await YTDLSource.from_url(queue[0], loop=client.loop)
voice_channel.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
await ctx.send('**Now playing:** {}'.format(player.title))
del(queue[0])