mirror of
https://github.com/TheShadowEevee/Konpeki-Discord-Bot.git
synced 2025-01-11 14:38:49 -06:00
Report server count anonymously with PM2
This commit is contained in:
parent
a8f447e7c4
commit
8bb74d9cd8
2 changed files with 21 additions and 0 deletions
16
index.js
16
index.js
|
@ -52,9 +52,13 @@ client.once(Events.ClientReady, c => {
|
||||||
metrics.websocketHeartbeatHist.update(latency);
|
metrics.websocketHeartbeatHist.update(latency);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
// Report current server count with PM2 (Servers counted anonymously)
|
||||||
|
metrics.serverCount.set(c.guilds.cache.size);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Client "on" Events
|
// Client "on" Events
|
||||||
|
// Someone used an interaction
|
||||||
client.on(Events.InteractionCreate, async interaction => {
|
client.on(Events.InteractionCreate, async interaction => {
|
||||||
if (!interaction.isChatInputCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
|
|
||||||
|
@ -99,5 +103,17 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Joined a server
|
||||||
|
client.on(Events.guildCreate, guild => {
|
||||||
|
// Report current server count with PM2 (Servers counted anonymously)
|
||||||
|
metrics.serverCount.set(guild.client.guilds.cache.size);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Removed from a server
|
||||||
|
client.on(Events.guildDelete, guild => {
|
||||||
|
// Report current server count with PM2 (Servers counted anonymously)
|
||||||
|
metrics.serverCount.set(guild.client.guilds.cache.size);
|
||||||
|
});
|
||||||
|
|
||||||
// Log in to Discord with your client's token
|
// Log in to Discord with your client's token
|
||||||
client.login(token);
|
client.login(token);
|
|
@ -22,6 +22,10 @@ const websocketHeartbeatHist = io.histogram({
|
||||||
measurement: 'mean',
|
measurement: 'mean',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const serverCount = io.metric({
|
||||||
|
name : 'Server Count',
|
||||||
|
});
|
||||||
|
|
||||||
const interactionSuccess = function() {
|
const interactionSuccess = function() {
|
||||||
interactionSuccessCounter.inc();
|
interactionSuccessCounter.inc();
|
||||||
interactionSuccessMeter.mark();
|
interactionSuccessMeter.mark();
|
||||||
|
@ -32,4 +36,5 @@ module.exports = {
|
||||||
interactionErrors,
|
interactionErrors,
|
||||||
interactionSuccess,
|
interactionSuccess,
|
||||||
websocketHeartbeatHist,
|
websocketHeartbeatHist,
|
||||||
|
serverCount,
|
||||||
};
|
};
|
Loading…
Reference in a new issue