def on_voice_state_update(self, before, after):
if before == self._client.user:
if after.voice.voice_channel != self._voice_channel:
log.warning('Client was disconnected from the voice channel')
await self.connect_voice()
return
# joining
if before.voice.voice_channel != self._voice_channel and after.voice.voice_channel == self._voice_channel:
with suppress(database.bot.IgnoredUserError):
if await self._database.interaction_check(int(after.id)):
await self._send_welcome_message(after)
await self._users.add_listener(int(after.id), direct=False)
# leaving
elif before.voice.voice_channel == self._voice_channel and after.voice.voice_channel != self._voice_channel:
try:
await self._users.remove_listener(int(after.id), direct=False)
except ValueError:
log.warning('Tried to remove {0} (ID: {0.id}) from listeners but the user was not listed'.format(after))
评论列表
文章目录