Skip to main content

Stat Reporter

Is a lightweight stat reporter module for NestCord. This module sends data from your bot to different monitoring bot services.

Usage

Once the installation process is complete, we can import the NestCordStatReporterModule with your NestCordModule into the root AppModule:

import { Module } from '@nestjs/common';
import { AppService } from './app.service';
import { NestCordModule,
NestCordStatReporterModule,
StatCronExpression,
NestCordLocalizationModule,
DefaultLocalizationAdapter,
UserResolver
} from '@globalart/nestcord';

@Module({
imports: [
NestCordModule.forRoot({
token: process.env.DISCORD_TOKEN,
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent
],
prefix: '!',
development: [process.env.DISCORD_TEST_GUILD]
}),
NestCordStatReporterModule.forRoot({
services: [
{
name: 'top.gg',
actions: [
{
name: 'name of the action',
url: 'https://top.gg/bots/:bot_id/stats',
bodyData: { server_count: '{{serverCount}}', shard_count: '{{shardCount}}' },
}
],
headerData: { Authorization: process.env.TOP_GG_TOKEN },
schedule: StatCronExpression.EVERY_5_MINUTES // or you can use crontab expression like */1 * * * * ,
},
],
}),
],
providers: [AppService]
})
export class AppModule {
}

In services, all the services on which the bot is monitored should be listed, and the request body should be passed. {{serverCount}} and {{shardCount}} will be automatically replaced.

Global Options

NestCordStatReporterModule interface:

PropertyTypeDescription
servicesServiceOption[]Services
proxyAxiosProxyConfig or undefinedProxy config
developmentbooleanIf true, module will disable
logbooleanSend log when sended the stats

ServiceOption interface:

PropertyTypeDescription
namestringService Name
urlstringAPI URL for posting the stats
proxyAxiosProxyConfig or undefinedProxy config
bodyDataobjectBody Data
headerDataobjectHeader Data
scheduleStatCronExpression or stringCrontab Expression

Congratulations! You have successfully register cronjob with NestCord!