import { WebSocketClient } from '@src/gateway/WebSocketClient' ; import { IdentifyOptions } from '@src/gateway/interfaces/IdentifyOptions' ; import { WebSocketClientStates } from '@src/constants' ; import { GatewayOpCodes } from '@discordoo/providers' ; export function identify ( client , options ) { const mode = ( client . sessionId && client . closeSequence > 0 ) && ( ! options . useReconnectOnly || options . forceResume ) ? 'resume' : 'identify' ; const { token } = options ; let d , op ; switch ( mode ) { case 'identify' : { const { intents , properties , presence , compress } = options ; client . status = WebSocketClientStates . IDENTIFYING ; op = GatewayOpCodes . IDENTIFY ; d = { token , intents , properties , presence : presence || undefined , compress , shard : [ client . id , client . manager . options . totalShards ] } ; } break ; case 'resume' : { client . status = WebSocketClientStates . RESUMING ; op = GatewayOpCodes . RESUME ; d = { token , session_id : client . sessionId ! , seq : client . closeSequence } ; } break ; } return { d , op } as unknown as any ; }