
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
discordbotlist
Advanced tools
Integrate with discordbotlist.com and support voting rewards and promote your bot's stats on the website.
Easily add support for voting and display your bot's stats on discordbotlist.com with just a few lines of code. This package provides support out of the box for discord.js and eris bots, but can easily be adapted to work with any library of your choosing.
This package requires Node 16 or newer. If you're using discord.js v14, you should already meet this requirement. Install discordbotlist using:
npm i --save discordbotlist
To post stats and fetch recent votes using this package, you'll need a discordbotlist API token. This is not your Discord bot token. Do not use your Discord bot token as an API token or webhook secret. To create an API token for your bot:
To use webhooks, you will first need to create a Webhook Secret. This is not your Discord bot token. Do not use your Discord bot token as an API token or webhook secret. To configure your bot's Webhook Secret:
For most, the easiest way to use this package will be by creating a client using the wrapper function for your library.
import { createDjsClient } from "discordbotlist";
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on("ready", () => {
const dbl = createDjsClient(DBL_API_TOKEN, client);
});
client.login(TOKEN);
import { createErisClient } from "discordbotlist";
import { Client } from "eris";
const client = new Client(TOKEN, { intents: ["guilds"] });
client.on("ready", () => {
const dbl = createErisClient(DBL_API_TOKEN, client);
});
client.connect();
After creating a client, you can start automatically posting your bot's stats to discordbotlist:
dbl.startPosting(/* optional interval, defaults to every hour */);
This package can be used to implement voting by either exposing a webhook endpoint discordbotlist will call, or periodically checking for recent votes. The former is recommended in most cases and should be preferred if it can be used for your bot.
This package provides express middleware that can be used to easily set up vote rewards using webhooks.
After creating a dbl client, it can be used to set up vote rewards with an event-based interface:
import express from "express";
const app = express();
app.use(express.json());
app.post("/dbl", dbl.webhook(DBL_WEBHOOK_SECRET));
dbl.on("vote", vote => {
console.log(`${vote.username}#${vote.discriminator} voted!`);
});
app.listen(PORT);
If you don't want to use a client, you can use the upvoteListener
function instead:
import { upvoteListener } from "discordbotlist";
import express from "express";
const app = express();
app.use(express.json());
app.post(
"/dbl",
upvoteListener(DBL_WEBHOOK_SECRET, vote => {
console.log(`${vote.username}#${vote.discriminator} voted!`);
})
);
app.listen(PORT);
If you're running in an environment where webhooks aren't suitable, you can also support voting by using polling. To use polling, call Client#startPolling
, then listen for the vote
event just like webhooks:
dbl.startPolling(/* optional interval, defaults to every five minutes */);
dbl.on("vote", vote => {
console.log(`${vote.username}#${vote.discriminator} voted!`);
});
If your bot uses slash commands, you can display your bot's commands on DBL! You can post your commands to DBL the same way you post them to Discord. Use Client#postBotCommands
to post your bot's commands:
dbl.postBotCommands([
{
name: "help",
description: "View a list of the bot's commands.",
},
]);
This package also provides a strongly typed interface for interacting with DBL's REST API if desired. All types and functionality for this API wrapper is accessible from discordbotlist/api
. For example, to manually post a bot's stats without a Client instance:
import { postBotStats } from "discordbotlist";
postBotStats(DBL_API_TOKEN, DISCORD_BOT_ID, {
guilds: 100,
users: 1000,
});
FAQs
Integrate with discordbotlist.com and support voting rewards and promote your bot's stats on the website.
The npm package discordbotlist receives a total of 393 weekly downloads. As such, discordbotlist popularity was classified as not popular.
We found that discordbotlist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.