2020-11-08 07:57:24 +00:00
|
|
|
import { User } from '../../structures/user.ts'
|
|
|
|
import { CLIENT_USER } from '../../types/endpoint.ts'
|
2020-11-25 11:53:40 +00:00
|
|
|
import { Resume } from '../../types/gateway.ts'
|
2021-04-04 05:42:15 +00:00
|
|
|
import type { Gateway, GatewayEventHandler } from '../mod.ts'
|
2020-11-01 11:22:09 +00:00
|
|
|
|
2020-11-25 11:53:40 +00:00
|
|
|
export const resume: GatewayEventHandler = async (
|
|
|
|
gateway: Gateway,
|
|
|
|
d: Resume
|
|
|
|
) => {
|
2020-11-01 11:22:09 +00:00
|
|
|
gateway.debug(`Session Resumed!`)
|
2021-01-24 18:36:19 +00:00
|
|
|
gateway.client.emit('resumed', gateway.shards?.[0] ?? 0)
|
2020-11-25 11:53:40 +00:00
|
|
|
if (gateway.client.user === undefined)
|
|
|
|
gateway.client.user = new User(
|
|
|
|
gateway.client,
|
|
|
|
await gateway.client.rest.get(CLIENT_USER())
|
|
|
|
)
|
2021-01-24 18:36:19 +00:00
|
|
|
gateway.client.emit('ready', gateway.shards?.[0] ?? 0)
|
2020-11-25 11:53:40 +00:00
|
|
|
}
|