Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions packages/discordjs-light/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AnalyticsBase, ApiEndpoints, ApplicationCommandType, AnalyticsOptions, ErrorCodes } from '@discordanalytics/core';
import {
AnalyticsBase,
ApiEndpoints,
ApplicationCommandType,
AnalyticsOptions,
ErrorCodes,
LocaleData
} from '@discordanalytics/core';
import npmPackageData from '../package.json';

/**
Expand Down Expand Up @@ -88,6 +95,13 @@ export default class DiscordAnalytics extends AnalyticsBase {
(c: any) => c.guilds.cache.map((guild: any) => guild.memberCount)
))?.flat() ?? []);

let guildLocales: LocaleData[] = []
this._client.guilds.cache.map((current: any) => guildLocales.find((x) => x.locale === current.preferredLocale) ?
++guildLocales.find((x) => x.locale === current.preferredLocale)!.number :
guildLocales.push({ locale: current.preferredLocale, number: 1 }));

this.stats_data.guildsLocales = guildLocales

await this.sendStats(this._client.user.id, guildCount, userCount, userInstallCount, guildMembers);
}, fast_mode ? 30000 : 300000);
}
Expand All @@ -103,13 +117,6 @@ export default class DiscordAnalytics extends AnalyticsBase {
this.debug(`[DISCORDANALYTICS] trackInteractions(${interaction.type}) triggered`);
if (!this._isReady) return this.error(ErrorCodes.INSTANCE_NOT_INITIALIZED);

this.updateOrInsert(
this.stats_data.guildsLocales,
(x) => x.locale === interaction.guild?.preferredLocale,
(x) => x.number++,
() => ({ locale: interaction.guild?.preferredLocale, number: 1 }),
);

this.updateOrInsert(
this.stats_data.locales,
(x) => x.locale === interaction.locale,
Expand Down
24 changes: 16 additions & 8 deletions packages/discordjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { AnalyticsBase, ApiEndpoints, ApplicationCommandType, AnalyticsOptions, ErrorCodes, InteractionType } from '@discordanalytics/core';
import {
AnalyticsBase,
ApiEndpoints,
ApplicationCommandType,
AnalyticsOptions,
ErrorCodes,
InteractionType,
Locale, LocaleData
} from '@discordanalytics/core';
import npmPackageData from '../package.json';

/**
Expand Down Expand Up @@ -89,6 +97,13 @@ export default class DiscordAnalytics extends AnalyticsBase {
(c: any) => c.guilds.cache.map((guild: any) => guild.memberCount)
))?.flat() ?? []);

let guildLocales: LocaleData[] = []
this._client.guilds.cache.map((current: any) => guildLocales.find((x) => x.locale === current.preferredLocale) ?
++guildLocales.find((x) => x.locale === current.preferredLocale)!.number :
guildLocales.push({ locale: current.preferredLocale, number: 1 }));

this.stats_data.guildsLocales = guildLocales

await this.sendStats(this._client.user.id, guildCount, userCount, userInstallCount, guildMembers);
}, fast_mode ? 30000 : 300000);
}
Expand All @@ -104,13 +119,6 @@ export default class DiscordAnalytics extends AnalyticsBase {
this.debug(`[DISCORDANALYTICS] trackInteractions(${interaction.type}) triggered`);
if (!this._isReady) return this.error(ErrorCodes.INSTANCE_NOT_INITIALIZED);

this.updateOrInsert(
this.stats_data.guildsLocales,
(x) => x.locale === interaction.guild?.preferredLocale,
(x) => x.number++,
() => ({ locale: interaction.guild?.preferredLocale, number: 1 })
);

this.updateOrInsert(
this.stats_data.locales,
(x) => x.locale === interaction.locale,
Expand Down
23 changes: 15 additions & 8 deletions packages/eris/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AnalyticsBase, ApiEndpoints, AnalyticsOptions, ErrorCodes, InteractionType } from '@discordanalytics/core';
import {
AnalyticsBase,
ApiEndpoints,
AnalyticsOptions,
ErrorCodes,
InteractionType,
Locale, LocaleData
} from '@discordanalytics/core';
import npmPackageData from '../package.json';

/**
Expand Down Expand Up @@ -73,6 +80,13 @@ export default class DiscordAnalytics extends AnalyticsBase {
const userCount = this._client.guilds.reduce((a: number, g: any) => a + g.memberCount, 0);
const guildMembers: number[] = this._client.guilds.map((guild: any) => guild.memberCount);

let guildLocales: LocaleData[] = []
this._client.guilds.map((current: any) => guildLocales.find((x) => x.locale === current.preferredLocale) ?
++guildLocales.find((x) => x.locale === current.preferredLocale)!.number :
guildLocales.push({ locale: current.preferredLocale, number: 1 }));

this.stats_data.guildsLocales = guildLocales;

await this.sendStats(this._client.user.id, guildCount, userCount, 0, guildMembers);
}, fast_mode ? 30000 : 300000);
}
Expand All @@ -88,13 +102,6 @@ export default class DiscordAnalytics extends AnalyticsBase {
this.debug('[DISCORDANALYTICS] trackInteractions() triggered');
if (!this._isReady) return this.error(ErrorCodes.INSTANCE_NOT_INITIALIZED);

this.updateOrInsert(
this.stats_data.guildsLocales,
(x) => x.locale === interaction.guild?.preferredLocale,
(x) => x.number++,
() => ({ locale: interaction.guild?.preferredLocale, number: 1 })
);

if (interaction.type === InteractionType.ApplicationCommand) {
const name = interactionNameResolver ? interactionNameResolver(interaction) : interaction.data.name;
this.updateOrInsert(
Expand Down
18 changes: 16 additions & 2 deletions packages/oceanic/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AnalyticsBase, ApiEndpoints, AnalyticsOptions, ErrorCodes, InteractionType } from '@discordanalytics/core';
import {
AnalyticsBase,
ApiEndpoints,
AnalyticsOptions,
ErrorCodes,
InteractionType,
LocaleData
} from '@discordanalytics/core';
import npmPackageData from '../package.json';

/**
Expand Down Expand Up @@ -77,7 +84,14 @@ export default class DiscordAnalytics extends AnalyticsBase {
const userInstallCount = this._client.application.approximateUserInstallCount
const guildMembers: number[] = this._client.guilds.map((guild: any) => guild.memberCount);

await this.sendStats(this._client.user.id, guildCount, userCount, 0, guildMembers);
let guildLocales: LocaleData[] = []
this._client.guilds.map((current: any) => guildLocales.find((x) => x.locale === current.preferredLocale) ?
++guildLocales.find((x) => x.locale === current.preferredLocale)!.number :
guildLocales.push({ locale: current.preferredLocale, number: 1 }));

this.stats_data.guildsLocales = guildLocales;

await this.sendStats(this._client.user.id, guildCount, userCount, userInstallCount, guildMembers);
}, fast_mode ? 30000 : 300000);
}

Expand Down