UNPKG

discord-analytics

Version:

A discord bot analytics to send your bot data

69 lines (68 loc) 2.65 kB
import { DiscordAnalyticsOptions, TrackGuildType } from "../utils/types"; /** * @class DiscordAnalytics * @description The Oceanic.js class for the DiscordAnalytics library. * @param {DiscordAnalyticsOptions} options - Configuration options. * @property {any} options.client - The Oceanic.js client to track events for. * @property {string} options.apiToken - The API token for DiscordAnalytics. * @property {boolean} options.sharded - /!\ Not compatible with Oceanic.js * @property {boolean} options.debug - Enable or not the debug mode /!\ MUST BE USED ONLY FOR DEVELOPMENT PURPOSES /!\ * @example * const { default: DiscordAnalytics } = require('discord-analytics/oceanic'); * const { Client } = require('oceanic.js'); * const client = new Client({ * auth: "Bot <YOUR_BOT_TOKEN>", * gateway: { * intents: ["GUILDS"] * } * }) * client.on('ready', () => { * const analytics = new DiscordAnalytics({ * client: client, * apiToken: 'YOUR_API_TOKEN' * }); * analytics.trackEvents(); * }); * client.connect(); * * // Check docs for more informations about advanced usages : https://docs.discordanalytics.xyz/get-started/installation/oceanic.js */ export default class DiscordAnalytics { private readonly _client; private readonly _apiToken; private readonly _sharded; private readonly _debug; private readonly _headers; private _isReady; constructor(options: Omit<DiscordAnalyticsOptions, "sharded">); /** * 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; }