From 0e71a0963dd7bd8ea23c0857d634f7532889b61c Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 12 Jul 2017 01:17:42 +0000 Subject: [PATCH] Discord Bots Org Stuff --- XiaoBot.js | 4 +++- package.json | 2 +- structures/Util.js | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/XiaoBot.js b/XiaoBot.js index 64e554f6..c2d437bc 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -16,7 +16,7 @@ const client = new CommandoClient({ messageCacheLifetime: 60, messageSweepInterval: 60 }); -const { carbon, dBots } = require('./structures/Util'); +const { carbon, dBots, dBotsOrg } = require('./structures/Util'); client.registry .registerDefaultTypes() @@ -117,6 +117,7 @@ client.on('guildCreate', async (guild) => { const count = guilds.reduce((prev, val) => prev + val, 0); carbon(count); dBots(count, client.user.id); + dBotsOrg(count, client.user.id); }); client.on('guildDelete', async (guild) => { @@ -125,6 +126,7 @@ client.on('guildDelete', async (guild) => { const count = guilds.reduce((prev, val) => prev + val, 0); carbon(count); dBots(count, client.user.id); + dBotsOrg(count, client.user.id); }); client.login(token); diff --git a/package.json b/package.json index 692651df..74f96116 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "27.1.2", + "version": "27.1.3", "description": "Your personal server companion.", "main": "Shard.js", "scripts": { diff --git a/structures/Util.js b/structures/Util.js index 3cad77b1..ed4e1ae1 100644 --- a/structures/Util.js +++ b/structures/Util.js @@ -1,5 +1,5 @@ const snekfetch = require('snekfetch'); -const { carbonKey, dbotsKey } = require('../config'); +const { carbonKey, dbotsKey, dbotsOrgKey } = require('../config'); class Util { static cleanXML(str) { @@ -30,6 +30,15 @@ class Util { .then(() => console.log('[CARBON] Successfully posted to Carbon.')) .catch((err) => console.error(`[CARBON] Failed to post to Carbon. ${err}`)); } + + static dBotsOrg(count, id) { + snekfetch + .post(`https://discordbots.org/api/bots/${id}/stats`) + .set({ Authorization: dbotsOrgKey }) + .send({ server_count: count }) + .then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.')) + .catch((err) => console.error(`[DBOTSORG] Failed to post to Discord Bots Org. ${err}`)); + } } module.exports = Util;