update things again

This commit is contained in:
Isaac 2021-03-04 10:18:48 +00:00
parent feeca9c64d
commit 499517d082
4 changed files with 26 additions and 22 deletions

View File

@ -127,21 +127,29 @@ class Bot extends Client {
})(); })();
} }
async postGuildData(guild) { async postStats() {
/** /**
* OH NO, TELEMETRY!? * OH NO, TELEMETRY!?
* Relax, you can see the source here: https://github.com/discord-tickets/stats * Relax, it just counts how many people are using DiscordTickets.
* 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 if (this.config.super_secret_setting) { // you can disable it if you really want
const fetch = require('node-fetch'); const fetch = require('node-fetch');
let members = (await guild.fetch()).approximateMemberCount; let tickets = await this.db.models.Ticket.count();
fetch(`https://telemetry.discordtickets.app/guild?id=${guild.id}&members=${members}`, { fetch(`https://stats.discordtickets.app/client?id=${this.user.id}&tickets=${tickets}`, {
method: 'post', method: 'post',
}).catch(e => { }).catch(e => {
// fail quietly, it doesn't really matter if it didn't work // 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); this.log.debug(e);
}); });
this.guilds.cache.forEach(async g => {
let members = (await g.fetch()).approximateMemberCount;
fetch(`https://stats.discordtickets.app/guild?id=${g.id}&members=${members}`, {
method: 'post',
}).catch(e => {
this.log.debug(e);
});
});
} }
} }

7
src/listeners/error.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
event: 'error',
execute: (client, error) => {
client.log.warn('The client encountered an error');
client.log.error(error);
}
};

View File

@ -3,6 +3,5 @@ module.exports = {
execute: async (client, guild) => { execute: async (client, guild) => {
client.log.info(`Added to ${guild.name}`); client.log.info(`Added to ${guild.name}`);
await guild.createSettings(); await guild.createSettings();
await client.postGuildData(guild);
} }
}; };

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
event: 'ready', event: 'ready',
once: true, once: true,
execute: (client) => { execute: async (client) => {
client.log.success(`Connected to Discord as "${client.user.tag}"`); client.log.success(`Connected to Discord as "${client.user.tag}"`);
@ -18,21 +18,11 @@ module.exports = {
}, client.config.presence.duration * 1000); }, client.config.presence.duration * 1000);
} }
/** if(client.config.super_secret_setting) {
* OH NO, TELEMETRY!? setInterval(async () => {
* Relax, it just counts how many people are using DiscordTickets. await client.postStats();
* You can see the source here: https://github.com/discord-tickets/stats }, 3600000);
*/ await client.postStats();
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));
} }
} }