Skip to content

Quick start

You need a server with Docker and a domain name pointing at it (for HTTPS), and a bot on discord.js 14.12 or later, or 15.

  1. Start the collector

    shardlens init writes docker-compose.yml, a Caddyfile, a .env with generated secrets and keys, and a bot.env holding the two settings your bot needs.

    Terminal window
    npx shardlens init --domain stats.example.com --app-id 123456789012345678
    cd shardlens && docker compose up -d

    Caddy gets a certificate for your domain, the collector creates its tables, and the dashboard is served at https://stats.example.com. The bot’s two settings are in bot.env.

  2. Install the SDK in your bot

    pnpm add @shardlens/discordjs
  3. Add three lines to your bot

    bot.ts
    import { createShardlens } from '@shardlens/discordjs';
    import { Client, GatewayIntentBits } from 'discord.js';
    const client = new Client({ intents: [GatewayIntentBits.Guilds] });
    createShardlens(client, {
    endpoint: process.env.SHARDLENS_URL!, // https://stats.example.com
    apiKey: process.env.SHARDLENS_INGEST_KEY!, // slk_ingest_…
    });
    await client.login(process.env.DISCORD_TOKEN);

    Copy the two lines from bot.env (SHARDLENS_URL and SHARDLENS_INGEST_KEY) to wherever your bot reads its settings, then delete bot.env.

  4. Open the dashboard

    Go to your domain and sign in with your read key (SHARDLENS_READ_KEY in .env), or with Discord once you have set up Discord sign-in. Run a command in your bot: the live tiles on the Overview count it within seconds, and the chart and checklist follow within a minute or two, without reloading.