diff --git a/config.json.example b/config.json.example index 1008754..ee6a4c9 100644 --- a/config.json.example +++ b/config.json.example @@ -9,6 +9,8 @@ "Server id where system commands can be used", "Another server id where system commands can be used" ], + "systemMessageChannelId": "", + "systemUserId": "", "embedColors": { "colorSuccess": "#23A55A", "colorWarning": "#F0B232", diff --git a/src/events/client/disconnect.js b/src/events/client/disconnect.js index 2006cf5..f026722 100644 --- a/src/events/client/disconnect.js +++ b/src/events/client/disconnect.js @@ -1,5 +1,7 @@ const path = require('node:path'); const logger = require(path.resolve('./src/services/logger.js')); +const { EmbedBuilder } = require('discord.js'); +const { systemMessageChannelId, systemUserId, embedColors, embedIcons } = require(path.resolve('./config.json')); module.exports = { name: 'disconnect', @@ -7,5 +9,19 @@ module.exports = { once: false, execute: async (client) => { logger.warn(`${client.user.tag} lost connection to Discord APIs. Disconnected.`); + + // send message to system message channel for event + if (systemMessageChannelId && systemUserId) { + await client.channels.cache.get(systemMessageChannelId).send({ + embeds: [ + new EmbedBuilder() + .setDescription( + `${embedIcons.warning} **${client.user.tag}** is **\`disconnected\`**!` + + `\n<@${systemUserId}>` + ) + .setColor(embedColors.colorWarning) + ] + }); + } } }; diff --git a/src/events/client/ready.js b/src/events/client/ready.js index 16aa507..bbafd62 100644 --- a/src/events/client/ready.js +++ b/src/events/client/ready.js @@ -1,7 +1,8 @@ const path = require('node:path'); const logger = require(path.resolve('./src/services/logger.js')); -const { Events, ActivityType, PresenceUpdateStatus } = require('discord.js'); +const { Events, ActivityType, PresenceUpdateStatus, EmbedBuilder } = require('discord.js'); const { postBotStats } = require(path.resolve('./src/utils/postBotStats.js')); +const { systemMessageChannelId, embedColors, embedIcons } = require(path.resolve('./config.json')); module.exports = { name: Events.ClientReady, @@ -21,5 +22,16 @@ module.exports = { // Post bot stats to bot lists in production process.env.NODE_ENV === 'production' ? postBotStats(client) : null; + + // send message to system message channel for event + if (systemMessageChannelId) { + await client.channels.cache.get(systemMessageChannelId).send({ + embeds: [ + new EmbedBuilder() + .setDescription(`${embedIcons.success} **${client.user.tag}** is now **\`online\`**!`) + .setColor(embedColors.colorSuccess) + ] + }); + } } }; diff --git a/src/events/client/reconnecting.js b/src/events/client/reconnecting.js index 3ece9a1..8eb22db 100644 --- a/src/events/client/reconnecting.js +++ b/src/events/client/reconnecting.js @@ -1,5 +1,7 @@ const path = require('node:path'); const logger = require(path.resolve('./src/services/logger.js')); +const { EmbedBuilder } = require('discord.js'); +const { systemMessageChannelId, systemUserId, embedColors, embedIcons } = require(path.resolve('./config.json')); module.exports = { name: 'reconnecting', @@ -7,5 +9,19 @@ module.exports = { once: false, execute: async (client) => { logger.warn(`${client.user.tag} is reconnecting to Discord APIs.`); + + // send message to system message channel for event + if (systemMessageChannelId && systemUserId) { + await client.channels.cache.get(systemMessageChannelId).send({ + embeds: [ + new EmbedBuilder() + .setDescription( + `${embedIcons.warning} **${client.user.tag}** is **\`reconnecting\`**!` + + `\n<@${systemUserId}>` + ) + .setColor(embedColors.colorWarning) + ] + }); + } } };