@bot.command(pass_context = True, help="make bot leave vc")
async def leave(ctx):
if ctx.voice_client:
await ctx.guild.voice_client.disconnect()
await ctx.send('disconnected from vc')
else:
await ctx.send('im not currently in a vc')
我试图让一个不和谐的机器人与不和谐的语音通道断开连接,但它不起作用。当我使用该命令时,机器人会发送“与 vc 断开连接”,但实际上并未断开连接。
直接使用“ctx.voice_client”。应该是这样的:
@bot.command(pass_context = True, help = "make bot leave vc")
async def leave(ctx):
if ctx.voice_client:
await ctx.voice_client.disconnect()
await ctx.send('disconnected from vc')
else:
await ctx.send('im not currently in a vc')