-
Notifications
You must be signed in to change notification settings - Fork 2
/
traffic.guildMemberRemove.ts
48 lines (40 loc) · 1.23 KB
/
traffic.guildMemberRemove.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as app from "#app"
const listener: app.Listener<"guildMemberRemove"> = {
event: "guildMemberRemove",
description: "Announces when a member leaves the server",
async run(member) {
if (!app.cache.ensure<boolean>("turn", true)) return
if (await app.isIgnored(member.guild.id)) return
const config = await app.getGuild(member.guild)
if (!config) return
if (member.user.bot) {
if (config.general_channel_id && config.bot_leave_message) {
const general = member.client.channels.cache.get(
config.general_channel_id,
)
if (general) {
await app.sendTemplatedEmbed(
general,
config.bot_leave_message,
app.embedReplacers(member),
)
}
}
} else {
if (member.guild.bans.cache.has(member.id)) return
if (config.general_channel_id && config.member_leave_message) {
const general = member.client.channels.cache.get(
config.general_channel_id,
)
if (general) {
await app.sendTemplatedEmbed(
general,
config.member_leave_message,
app.embedReplacers(member),
)
}
}
}
},
}
export default listener