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
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -22,6 +23,6 @@ jobs:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
@anolilab/multi-semantic-release
@anolilab/semantic-release-pnpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 11 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{ "type": "refactor", "release": "patch" },
{ "type": "chore", "release": "patch" },
{ "type": "ci", "release": "patch" }
]
}
],
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
Expand All @@ -13,7 +22,7 @@
"@semantic-release/github"
],
"extends": [
"@anolilab/multi-semantic-release"
"@anolilab/semantic-release-pnpm"
],
"dryRun": false
}
4 changes: 4 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class AnalyticsBase {
private_message: 0,
},
custom_events: {} as Record<string, number>,
user_install_count: 0,
};
public client_id: string = '';

Expand Down Expand Up @@ -160,13 +161,15 @@ export class AnalyticsBase {
* @param client_id The client ID of the bot
* @param guild_count The number of guilds the bot is in (default: 0)
* @param user_count The number of users the bot is in (default: 0)
* @param user_install_count The number of user installs (default: 0)
* @param guild_members The number of members in each guild (optional)
* @returns {Promise<void>} A promise that resolves when the stats are sent
*/
public async sendStats(
client_id: string,
guild_count: number = 0,
user_count: number = 0,
user_install_count: number = 0,
guild_members: number[] = [],
): Promise<void> {
this.debug('[DISCORDANALYTICS] Sending stats...');
Expand Down Expand Up @@ -197,6 +200,7 @@ export class AnalyticsBase {
private_message: 0,
},
custom_events: this.stats_data.custom_events,
user_install_count,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/discordjs-light/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ export default class DiscordAnalytics extends AnalyticsBase {
? ((await this._client.shard?.broadcastEval((c: any) => c.guilds.cache.reduce((a: number, g: any) => a + (g.memberCount || 0), 0)))?.reduce((a: number, b: number) => a + b, 0) || 0)
: this._client.guilds.cache.reduce((a: number, g: any) => a + (g.memberCount || 0), 0);

const userInstallCount = this._sharded
? ((await this._client.shard?.broadcastEval((c: any) => c.approximateUserInstallCount))?.reduce((a: number, b: number) => a + b, 0) || 0)
: this._client.approximateUserInstallCount;

const guildMembers: number[] = !this._sharded
? this._client.guilds.cache.map((guild: any) => guild.memberCount)
: ((await this._client.shard?.broadcastEval(
(c: any) => c.guilds.cache.map((guild: any) => guild.memberCount)
))?.flat() ?? []);

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

Expand Down
6 changes: 5 additions & 1 deletion packages/discordjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ export default class DiscordAnalytics extends AnalyticsBase {
? ((await this._client.shard?.broadcastEval((c: any) => c.guilds.cache.reduce((a: number, g: any) => a + (g.memberCount || 0), 0)))?.reduce((a: number, b: number) => a + b, 0) || 0)
: this._client.guilds.cache.reduce((a: number, g: any) => a + (g.memberCount || 0), 0);

const userInstallCount = this._sharded
? ((await this._client.shard?.broadcastEval((c: any) => c.approximateUserInstallCount))?.reduce((a: number, b: number) => a + b, 0) || 0)
: this._client.approximateUserInstallCount;

const guildMembers: number[] = !this._sharded
? this._client.guilds.cache.map((guild: any) => guild.memberCount)
: ((await this._client.shard?.broadcastEval(
(c: any) => c.guilds.cache.map((guild: any) => guild.memberCount)
))?.flat() ?? []);

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

Expand Down
2 changes: 1 addition & 1 deletion packages/eris/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ 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);

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

Expand Down
13 changes: 11 additions & 2 deletions packages/oceanic/examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import DiscordAnalytics from '../src/index';
import { ApplicationCommandOptionTypes, ApplicationCommandTypes, ButtonStyles, Client, ComponentTypes, InteractionTypes, TextInputStyles } from 'oceanic.js';
import {
Application,
ApplicationCommandOptionTypes,
ApplicationCommandTypes,
ButtonStyles,
Client,
ComponentTypes,
InteractionTypes,
TextInputStyles
} from 'oceanic.js';
import 'dotenv/config';

const client = new Client({
Expand Down Expand Up @@ -126,7 +135,7 @@ client.on('interactionCreate', async (interaction) => {
components: [],
});
} else if (interaction.isModalSubmitInteraction()) {
const input = interaction.data.components.getComponents()[0].value;
const input = interaction.data.components.getComponents()[0].customID;
interaction.reply({
content: `You submitted the modal! ${input}`,
});
Expand Down
3 changes: 2 additions & 1 deletion packages/oceanic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ export default class DiscordAnalytics extends AnalyticsBase {

const guildCount = this._client.guilds.toArray().length;
const userCount = this._client.guilds.reduce((a: number, g: any) => a + (g.memberCount || 0), 0);
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, guildMembers);
await this.sendStats(this._client.user.id, guildCount, userCount, 0, guildMembers);
}, fast_mode ? 30000 : 300000);
}

Expand Down