mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 14:38:49 +00:00
fix: Add support for sending client ready, reconnect and disconnect events to system channel
This commit is contained in:
1 parent
fab043a308
commit
6fdd943e56
4 files changed
+47
-1
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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)
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user