discord-analytics

2.4.0 • Public • Published

Discord Analytics

Installing the package

npm install discord-analytics

Usage

Note: To use Discord Analytics, you need to have an API token. Check the docs for more informations : https://docs.discordanalytics.xyz/get-started/bot-registration

With Discord.js:

// Import Discord.js's client and intents
const { Client, IntentsBitField } = require("discord.js")
// import discord-analytics
const { default: DiscordAnalytics } = require("discord-analytics/discordjs")

// Create Discord client
const client = new Client({
    intents: [IntentsBitField.Flags.Guilds] // This intent is required
});

// Create Discord Analytics instance
// Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
const analytics = new DiscordAnalytics({
    client: client,
    apiToken: 'YOUR_API_TOKEN',
    sharded: false // Set it to true if your bot use shards
});

// start tracking selected events
analytics.trackEvents();

// When Discord client is ready
client.on('ready', () => {
    console.log("Bot is ready!");
});

// Login to Discord
// Don't forget to replace token by your Discord bot token !
client.login('token');

With Eris:

const {Client} = require("eris");
const {default: DiscordAnalytics} = require("discord-analytics/eris");

// Create Eris client.
// Don't forget to replace token by your Discord bot token !
const bot = new Client("token");

bot.on("ready", () => {
    // Create Discord Analytics instance
    // Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
    const analytics = new DiscordAnalytics({
        client: client,
        apiToken: 'YOUR_API_TOKEN'
    });

    // start tracking selected events
    analytics.trackEvents();

    console.log("Ready!");
});

// Login to Discord
bot.connect();

With Oceanic.js:

// Import Discord.js's client and intents
const { Client } = require("oceanic.js")
// import discord-analytics
const { default: DiscordAnalytics } = require("discord-analytics/oceanic")

// Create Discord client
const client = new Client({
  auth: "Bot <YOUR_BOT_TOKEN>",
  gateway: {
    intents: ["GUILDS"] // This intent is required
  }
})

// Create Discord Analytics instance
// Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
const analytics = new DiscordAnalytics({
  client: client,
  apiToken: 'YOUR_API_TOKEN'
});

// start tracking selected events
analytics.trackEvents();

// When Discord client is ready
client.on('ready', () => {
  console.log("Bot is ready!");
});

// Login to Discord
// Don't forget to replace token by your Discord bot token !
client.login('token');

For advanced usages and updated docs, please check https://docs.discordanalytics.xyz/get-started/installation

Package Sidebar

Install

npm i discord-analytics

Weekly Downloads

128

Version

2.4.0

License

MIT

Unpacked Size

79.1 kB

Total Files

15

Last publish

Collaborators

  • valredstone
  • nonolanlan1007