An typescript API wrapper for the discordlist.gg api.
npm install dlist.js



discord.js and eirs.
bash
With npm
npm install dlist.js
With yarn
yarn add dlist.js
`
For node.js v17 or lower, use
`bash
With npm
npm install dlist.js node-fetch@2
With yarn
yarn add dlist.js node-fetch@2
`
Getting API Token
To be able to interact with the api, you have to create a client, in the client's option you have to provide the [discordlist.gg]()-token.
To get your token please visit https://discordlist.gg/bot/ and look for the Token section.
Create Client
`ts
/ ES6 /
import { Client } from 'dlist.js';
// import { Client as dlistClient } from 'dlist.js';
/ commonJS /
const { Client } = require('dlist.js');
// const { Client: dlistClient } = require('dlist.js');
const client = new Client({
token: 'xxx',
bot: '857230367350063104',
/ If using voting webhook (optional) /
webhook: {
port: 3000,
authorization: 'abc',
listenCallback: () => console.log('web server ready')
}
});
`
Posting Guild data
Send your bot's server count stats to dlist.gg api so it can be displayed for your bot on the website!
If you're using for example discord.js, replace 500 with client.guilds.cache.size. If you're using any other package, please read their docs or ask the package maintainers.
`ts
client.postGuilds(500);
`
Voting webhook
If you use this, you have to add the 'webhook' part in #Getting API Token to be able to recieve events.
Next, head over to https://discordlist.gg/bot/ again and enter your server's IP and Port in the Webhook URl field, for example: http://123.456.78:3000.
In the Webhook Authorization field, create a strong key and treat it like a password, the same value has to be entered in the #Create Dlist Client.webhook.authorization in order to work!
`ts
client.on('vote', data => {
console.log(data);
/*
{
user_id: '857230367350063104',
bot_id: '821472922140803112',
is_test: true
}
*/
});
``