📢

Check out 📺 DisWidgets - 🎨 Free, Stylish and Simple.

Infinity Bot List API 🛰️
A "How to" guide on using Infinity Bot List REST API.
ven profile picture

Anaxes • 📆 Published on November 9, 2021 • 🍿 3 min read

For this guide, I'll be using JavaScript package, specifically a Node.js API wrapper.

💻 Installing the API wrapper

To install the API wrapper, head to a website called npm (node package manager).

Once you have done that, run the following through the command line (terminal):

💻‎console
# @latest meaning it installs the latest version.
npm i [email protected]

# @v# meaning it installs a specifc version.
npm i [email protected]

By now, you would have noticed that your package.json & package-lock.json files have been updated. Don't worry, that's a good thing. It means that the package has successfully been installed.

Using the Package

Now, let's start using the package within our code.

First, create a file ending with the file extension .js.

💻‎.js
const Discord = require("discord.js")
const client = new Discord.Client()
const infinityBotListApi = require("infinityapi.js") // Requiring the package we just installed.
const IBL = new infinityBotListApi(client.user.id, "your_bot_token")

client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}.`)
setInterval(() => {
   IBL.post(client.guilds.cache.size, '0') // Server Count and 0 Shards
  })
}, 300000); /* 5 minutes in milliseconds. */

client.on("message", message => {
    const prefix = "!";
    if(message.author.bot) return;
    if(message.content === prefix + "ping"){
        message.reply(`Pong! it took ${client.ws.ping}`)
    }
});

client.login("your_bot_token");

TypeScript Using the Package (TypeScript Edition)

💻‎.ts
import Discord from "discord.js";
const client = new Discord.Client();
import infinityBotListApi from "infinityapi.js"; // Requiring the package we just installed.
const IBL = new infinityBotListApi(client.user.id, "your_bot_token");

client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}.`)
setInterval(() => {
   IBL.post(client.guilds.cache.size, '0') // Server Count and 0 Shards
  })
}, 300000); /* 5 minutes in milliseconds. */

client.on("message", message => {
    const prefix:string = "!";
    if(message.author.bot) return;
    if(message.content === prefix + "ping"){
        message.reply(`Pong! it took ${client.ws.ping}`)
    }
});

client.login("your_bot_token");