-
Notifications
You must be signed in to change notification settings - Fork 0
/
presenceUpdate.js
49 lines (45 loc) · 2.38 KB
/
presenceUpdate.js
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
49
const { MessageEmbed } = require("discord.js");
const moment = require("moment");
module.exports = async(manager, oldPresence, newPresence) => {
if (!oldPresence || !newPresence) return;
if (oldPresence.status === newPresence.status) return;
if (newPresence.userId !== "YOUR_DISCORD_BOT_ID") return;
const channel = oldPresence.guild.channels.cache.find(chan => chan.id === "YOUR_CHANNEL_LOGGING_ID") || null;
const bot = manager.users.cache.get("YOUR_DISCORD_BOT_ID");
const incidentDate = moment().format('LLL')
if (channel !== null) {
if (newPresence.status === 'offline') {
const botSleeping = new MessageEmbed()
.setThumbnail('https://i.imgur.com/l2HornC.png')
.setTitle(`Application: BOT_NAME`)
.setDescription(`BOT_NAME has gone offline unexpectedly. Developers are aware!`)
.addField(`Incident Date/Time`, `${incidentDate}`)
.setColor("#E2574C")
channel.send({ embeds: [botSleeping] })
} else if (newPresence.status === 'online') {
const botAwoken = new MessageEmbed()
.setThumbnail('https://i.imgur.com/s1GZ8ah.png')
.setTitle(`Application: BOT_NAME`)
.setDescription(`BOT_NAME is now back online and ready to serve your server!`)
.addField(`Incident Date/Time`, `${incidentDate}`)
.setColor("#3DB39E")
channel.send({ embeds: [botAwoken] })
} else if (newPresence.status === 'dnd') {
const botDownTime = new MessageEmbed()
.setThumbnail('https://i.imgur.com/l2HornC.png')
.setTitle(`Application: BOT_NAME`)
.setDescription(`BOT_NAME has stopped working due to an internal error!`)
.addField(`Incident Date/Time`, `${incidentDate}`)
.setColor("#f5d870")
channel.send({ embeds: [botDownTime] })
} else if (newPresence.status === 'idle') {
const botUpgrade = new MessageEmbed()
.setThumbnail('https://i.imgur.com/OjGZA28.png')
.setTitle(`Application: BOT_NAME`)
.setDescription(`BOT_NAME has gone down for maintenance!`)
.addField(`Incident Date/Time`, `${incidentDate}`)
.setColor("#f5d870")
channel.send({ embeds: [botUpgrade] })
}
}
}