2020-12-02 12:29:52 +00:00
|
|
|
import { PresenceUpdatePayload } from '../../types/gateway.ts'
|
|
|
|
import { Gateway, GatewayEventHandler } from '../index.ts'
|
|
|
|
|
|
|
|
export const presenceUpdate: GatewayEventHandler = async (
|
|
|
|
gateway: Gateway,
|
|
|
|
d: PresenceUpdatePayload
|
|
|
|
) => {
|
|
|
|
const guild = await gateway.client.guilds.get(d.guild_id)
|
|
|
|
if (guild === undefined) return
|
|
|
|
|
|
|
|
await guild.presences.set(d.user.id, d)
|
|
|
|
const presence = await guild.presences.get(d.user.id)
|
|
|
|
if (presence === undefined) return
|
|
|
|
|
|
|
|
gateway.client.emit('presenceUpdate', presence)
|
|
|
|
}
|