From feeca9c64d57f5b67b33558c005e925437fd3fb5 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 3 Mar 2021 21:19:51 +0000 Subject: [PATCH] update things --- src/index.js | 18 ++++++++++++++++++ src/listeners/guildCreate.js | 1 + src/listeners/ready.js | 36 ++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index be7b0dc..f5ddaec 100644 --- a/src/index.js +++ b/src/index.js @@ -127,6 +127,24 @@ class Bot extends Client { })(); } + async postGuildData(guild) { + /** + * OH NO, TELEMETRY!? + * Relax, you can see the source here: https://github.com/discord-tickets/stats + */ + if (this.config.super_secret_setting) { // you can disable it if you really want + const fetch = require('node-fetch'); + let members = (await guild.fetch()).approximateMemberCount; + fetch(`https://telemetry.discordtickets.app/guild?id=${guild.id}&members=${members}`, { + method: 'post', + }).catch(e => { + // fail quietly, it doesn't really matter if it didn't work + this.log.debug('Warning: failed to post to telemetry.discordtickets.app/guild'); + this.log.debug(e); + }); + } + } + } new Bot(); diff --git a/src/listeners/guildCreate.js b/src/listeners/guildCreate.js index 375722a..677699a 100644 --- a/src/listeners/guildCreate.js +++ b/src/listeners/guildCreate.js @@ -3,5 +3,6 @@ module.exports = { execute: async (client, guild) => { client.log.info(`Added to ${guild.name}`); await guild.createSettings(); + await client.postGuildData(guild); } }; \ No newline at end of file diff --git a/src/listeners/ready.js b/src/listeners/ready.js index 1e2bdb4..aa7fde1 100644 --- a/src/listeners/ready.js +++ b/src/listeners/ready.js @@ -2,25 +2,8 @@ module.exports = { event: 'ready', once: true, execute: (client) => { - const { log } = client; - log.success(`Connected to Discord as "${client.user.tag}"`); - - /** - * OH NO, TELEMETRY!? - * Relax, it just counts how many people are using DiscordTickets. - * You can see the source here: https://github.com/discord-tickets/stats - */ - if (client.config.super_secret_setting) { // you can disable it if you really want - const fetch = require('node-fetch'); - fetch(`https://telemetry.discordtickets.app/client?id=${client.user.id}`, { - method: 'post', - }).catch(e => { - // fail quietly, it doesn't really matter if it didn't work - log.debug('Warning: failed to post to telemetry.discordtickets.app/client'); - log.debug(e); - }); - } + client.log.success(`Connected to Discord as "${client.user.tag}"`); client.commands.load(); // load internal commands @@ -34,6 +17,23 @@ module.exports = { client.log.debug(`Updated presence: ${presence.activity.type} ${presence.activity.name}`); }, client.config.presence.duration * 1000); } + + /** + * OH NO, TELEMETRY!? + * Relax, it just counts how many people are using DiscordTickets. + * You can see the source here: https://github.com/discord-tickets/stats + */ + if (client.config.super_secret_setting) { // you can disable it if you really want + const fetch = require('node-fetch'); + fetch(`https://telemetry.discordtickets.app/client?id=${client.user.id}`, { + method: 'post', + }).catch(e => { + // fail quietly, it doesn't really matter if it didn't work + client.log.debug('Warning: failed to post to telemetry.discordtickets.app/client'); + client.log.debug(e); + }); + client.guilds.cache.forEach(async g => await client.postGuildData(g)); + } } }; \ No newline at end of file