Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Add metrics tracking for users and guilds in messageCreate.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrlolDev committed Apr 5, 2024
1 parent a298144 commit eecbb55
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bot/events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ export const messageCreate = async (message: Message, bot: Bot) => {

let previousMetrics: any = (await getCache("metrics_shapes")) || {
users: [],
usersCount: 0,
guilds: [],
guildsCount: 0,
messages: 0,
};
let userIsThere = previousMetrics?.users.find(
(u: string) => u === message.author.id.toString()
);
if (!userIsThere) {
previousMetrics?.users.push(message.author.id.toString());
previousMetrics.usersCount++;
}
if (message.guildId) {
let guildIsThere = previousMetrics?.guilds.find(
(g: string) => g === message.guildId?.toString()
);
if (!guildIsThere) {
previousMetrics?.guilds.push(message.guildId?.toString());
previousMetrics.guildsCount++;
}
}

Expand Down

0 comments on commit eecbb55

Please sign in to comment.