擅长:python、mysql、java
<p>如果服务器中没有<code>VoiceClient</code>,那么{a1}将返回{<cd3>}。在尝试断开连接之前,您应该检查一下。在</p>
<pre><code>@client.command(name = "leave",
pass_context = True)
async def leave(ctx):
server = ctx.message.server
voice_client = client.voice_client_in(server)
if voice_client:
await voice_client.disconnect()
print("Bot left the voice channel")
else:
print("Bot was not in channel")
</code></pre>