mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 07:46:43 +02:00
Attempt to Add Logger Functionality
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { CommandoClient } = require('discord.js-commando');
|
||||
const { discordBots, carbon } = require('./poststats.js');
|
||||
const { discordBots, carbon, webhook } = require('./poststats.js');
|
||||
const path = require('path');
|
||||
const client = new CommandoClient({
|
||||
commandPrefix: 'x;',
|
||||
@@ -33,6 +33,7 @@ client.on('guildCreate', async(guild) => {
|
||||
const guilds = await client.shard.fetchClientValues('guilds.size');
|
||||
const count = guilds.reduce((prev, val) => prev + val, 0);
|
||||
console.log(`[Count] ${count}`);
|
||||
webhook(`Joined ${guild.name}!`, `Shard ${client.shard.id}`, 0x33CC33);
|
||||
try {
|
||||
const carbonStats = await carbon(count);
|
||||
console.log(`[Carbon] Successfully posted to Carbon. ${carbonStats}`);
|
||||
@@ -52,6 +53,7 @@ client.on('guildDelete', async(guild) => {
|
||||
const guilds = await client.shard.fetchClientValues('guilds.size');
|
||||
const count = guilds.reduce((prev, val) => prev + val, 0);
|
||||
console.log(`[Count] ${count}`);
|
||||
webhook(`Left ${guild.name}...`, `Shard ${client.shard.id}`, 0xFF3300);
|
||||
try {
|
||||
const carbonStats = await carbon(count);
|
||||
console.log(`[Carbon] Successfully posted to Carbon. ${carbonStats}`);
|
||||
@@ -67,7 +69,8 @@ client.on('guildDelete', async(guild) => {
|
||||
});
|
||||
|
||||
client.on('disconnect', (event) => {
|
||||
console.log(`[Disconnect] The Shard ${client.shard.id} disconnected with Code ${event.code}.`);
|
||||
console.log(`[Disconnect] Shard ${client.shard.id} disconnected with Code ${event.code}.`);
|
||||
webhook(`Disconnected...`, `Shard ${client.shard.id}`, 0xFF3300);
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
|
||||
@@ -21,3 +21,19 @@ module.exports.carbon = async(count) => {
|
||||
});
|
||||
return text;
|
||||
};
|
||||
|
||||
module.exports.webhook = async(description, author, color) => {
|
||||
const embed = {
|
||||
description: description,
|
||||
author: {
|
||||
name: author
|
||||
},
|
||||
color: color
|
||||
};
|
||||
await request
|
||||
.post(process.env.LOGGER_URL)
|
||||
.send({
|
||||
embeds: [embed]
|
||||
});
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user