UNPKG

discord-analytics

Version:

A discord bot analytics to send your bot data

66 lines (65 loc) 2.64 kB
import { DiscordAnalyticsOptions, TrackGuildType } from "../utils/types"; /** * @class DiscordAnalytics * @description The Discord.js-light class for the DiscordAnalytics library. * @param {DiscordAnalyticsOptions} options - Configuration options. * @property {any} options.client - The Discord.js-light client to track events for. * @property {string} options.apiToken - The API token for DiscordAnalytics. * @property {boolean} options.sharded - Whether the Discord.js-light client is sharded. * @property {boolean} options.debug - Enable or not the debug mode /!\ MUST BE USED ONLY FOR DEVELOPMENT PURPOSES /!\ * @example * const { default: DiscordAnalytics } = require('discord-analytics/discord.js-light'); * const { Client, IntentsBitField } = require('discord.js-light'); * const client = new Client({ * intents: ["GUILDS"] * }) * client.on('ready', () => { * const analytics = new DiscordAnalytics({ * client: client, * apiToken: 'YOUR_API_TOKEN' * }); * analytics.trackEvents(); * }); * client.login('YOUR_BOT_TOKEN'); * * // Check docs for more informations about advanced usages : https://docs.discordanalytics.xyz/get-started/installation/discord.js */ export default class DiscordAnalytics { private readonly _client; private readonly _apiToken; private readonly _sharded; private readonly _debug; private readonly _headers; private _isReady; constructor(options: DiscordAnalyticsOptions); /** * Initialize DiscordAnalytics on your bot * /!\ Advanced users only * /!\ Required to use DiscordAnalytics (except if you use the trackEvents function) * /!\ Must be used when the client is ready (recommended to use in ready event to prevent problems) */ init(): Promise<void>; private statsData; private calculateGuildMembersRepartition; /** * Track interactions * /!\ Advanced users only * /!\ You need to initialize the class first * @param interaction - BaseInteraction class and its extensions only */ trackInteractions(interaction: any): Promise<void>; /** * Track guilds * /!\ Advanced users only * /!\ You need to initialize the class first * @param guild - The Guild instance only * @param {TrackGuildType} type - "create" if the event is guildCreate and "delete" if is guildDelete */ trackGuilds(guild: any, type: TrackGuildType): Promise<void>; /** * Let DiscordAnalytics declare the events necessary for its operation. * /!\ Not recommended for big bots * /!\ Not compatible with other functions */ trackEvents(): void; }