Skip to content
Chethan Yadav
Work

Engineering/2021/Active

DisBotlist API

The official API powering DisBotlist.

JavaScriptDiscord.js

Overview

disbotlist-api is the client library bot owners install to talk to DisBotlist's stats API — published to npm as disbotlist (a separately maintained disbotlist.py package covers Python bots). It wraps the three HTTP calls a listed bot actually needs: post its live server count, check whether a user has voted for it, and look up another bot's public listing.

It's intentionally small — one class, three methods, a single dependency (node-fetch). You construct it with your bot's DisBotlist token and your discord.js client instance; it reads client.guilds.cache.size for you when posting stats.

Installation

npm i disbotlist

Usage

const disbot = require("disbotlist");
const dbl = new disbot("YOUR-DISBOTLIST-TOKEN", client);
 
client.on("ready", async () => {
  // Post this bot's current server count
  dbl.serverCount();
 
  // Check whether a user has voted for this bot
  const voted = await dbl.hasVoted("USER-ID");
  console.log(voted ? "Voted" : "Not voted yet");
 
  // Look up another bot's public listing
  const bot = await dbl.search("BOT-ID");
  console.log(bot.username, bot.votes, bot.tags);
});

search() returns the same JSON the public bot-lookup endpoint returns: avatar, botID, username, discrim, shortDesc, prefix, votes, ownerID, owner, coowners, tags, longDesc, certificate, plus github / support / website links when the listing has them.

How It Works

Each method is a thin fetch call against DisBotlist's live API:

MethodRequest
serverCount()POST /api/bots/stats with serverCount and Authorization headers
hasVoted(id)GET /api/bots/check/:userID with an Authorization header, returns .voted
search(id)GET /api/bots/:botID — no auth required

The Authorization header is the bot's own DisBotlist token, not a user OAuth token, so serverCount() and hasVoted() only ever act on the bot that token belongs to. There's no build step or bundler — it's plain CommonJS, meant to be dropped straight into a discord.js bot's ready handler.

View on GitHub ↗ · npm package ↗ · Live ↗ · DisBotlist platform ↗