这是我的 leave 命令 atm 代码:
@commands.command(name='leave', aliases=['disconnect'])
@commands.cooldown(1, 2, commands.BucketType.user)
@commands.has_permissions(manage_guild=True)
async def _leave(self, ctx: commands.Context):
await ctx.voice_state.stop()
del self.voice_states[ctx.guild.id]
答案 0 :(得分:1)
假设您正在寻找 3 分钟无人在 vc 后超时,请尝试将其作为起点:
import asyncio
@commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
if len(self.bot.get_guild(id).voice_client.channel.members) < 1:
asyncio.sleep(180)
if len(self.bot.get_guild(id).voice_client.channel.members) < 1:
await self.bot.get_guild(id).voice_client.disconnect()