2020-12-02 12:29:52 +00:00
|
|
|
import { Guild } from '../../structures/guild.ts'
|
|
|
|
import { GuildPayload } from '../../types/guild.ts'
|
|
|
|
import { Gateway, GatewayEventHandler } from '../index.ts'
|
|
|
|
|
2020-12-03 05:28:20 +00:00
|
|
|
export const guildDelete: GatewayEventHandler = async (
|
2020-12-02 12:29:52 +00:00
|
|
|
gateway: Gateway,
|
|
|
|
d: GuildPayload
|
|
|
|
) => {
|
|
|
|
const guild: Guild | undefined = await gateway.client.guilds.get(d.id)
|
|
|
|
|
|
|
|
if (guild !== undefined) {
|
|
|
|
await guild.members.flush()
|
|
|
|
await guild.channels.flush()
|
|
|
|
await guild.roles.flush()
|
|
|
|
await guild.presences.flush()
|
|
|
|
await gateway.client.guilds.delete(d.id)
|
|
|
|
|
|
|
|
gateway.client.emit('guildDelete', guild)
|
|
|
|
}
|
|
|
|
}
|