@client.command()
async def join(ctx):
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='General')
await voiceChannel.connect()
如果有人断开机器人连接(不移动)而只是断开连接,我该如何重新连接?
答案 0 :(得分:0)
使用 on_voice_state_update(member, before, after)
,如果机器人断开与语音通道的连接,您可能会得到:
@client.event
async def on_voice_state_update(member, before, after):
if member.id == client.user.id and after.channel == None and before.channel != None:
voiceChannel = before.channel
await voiceChannel.connect()
这需要启用 Intents.voice_states:
参考文献: