Attempt to Add Logger Functionality

This commit is contained in:
Daniel Odendahl Jr
2017-04-24 01:54:06 +00:00
parent 11a610ab5e
commit b04e200c6d
2 changed files with 21 additions and 2 deletions
+5 -2
View File
@@ -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);
});
+16
View File
@@ -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;
};