Radarcord-js

The best way to interact with the Radarcord API!

Features

  • Easy to use

  • Supports discord.js and will support eris soon.

  • Supports TypeScript

  • May come with Webhook support soon.

Installation

npm install @yoshiboi18303/radarcord-js

Basic discord.js Usage

const Discord = require("discord.js");
const { Client: Radar } = require("@yoshiboi18303/radarcord-js");

const client = new Discord.Client({
    intents: new Discord.IntentsBitField(["Guilds"]),
});
const radar = new Radar(client, "myradarcordauthtoken"); // Make sure to replace myradarcordauthtoken with your actual Radarcord auth token.

client.on("ready", async () => {
    console.log("The client is ready!")
    await radar.postStats(); // Send a stats post to the Radarcord API.
});

client.login("YOUR_TOKEN_HERE"); // Make sure to replace YOUR_TOKEN_HERE with your Discord bot's token.

Basic eris Usage

const Eris = require("eris");
// Note that we're importing ErisClient here rather than Client.
const { ErisClient: Radar } = require("@yoshiboi18303/radarcord-js");

const client = Eris("YOUR_TOKEN_HERE", /* Make sure to replace YOUR_TOKEN_HERE with your Discord bot's token. */ {
    intents: ["guilds"],
});
const radar = new Radar(client, "myradarcordauthtoken"); // Make sure to replace myradarcordauthtoken with your actual Radarcord auth token.

client.on("ready", async () => {
    console.log("The client is ready!");
    await radar.postStats(); // Send a stats post to the Radarcord API.
});

client.connect();

These next methods are the same for discord.js and eris if you're using eris, use the class in the Basic Eris Usage section.

Autoposting Usage

const Discord = require("discord.js");
const { Client: Radar } = require("@yoshiboi18303/radarcord-js");
const { IntervalPreset } = require("@yoshiboi18303/radarcord-js/dist/utils");

const client = new Discord.Client({
    intents: new Discord.IntentsBitField(["Guilds"]),
});
const radar = new Radar(client, "myradarcordauthtoken"); // Make sure to replace myradarcordauthtoken with your actual Radarcord auth token.

client.on("ready", async () => {
    console.log("The client is ready!")
    // The timeoutInterval argument defaults to IntervalPreset.Default (120 seconds) if not passed in.
    await radar.autopostStats();
    // You can also pass in your own time interval!
    await radar.autopostStats(1 /* shardCount */, IntervalPreset.Safe /* timeoutInterval */);
});

client.login("YOUR_TOKEN_HERE"); // Make sure to replace YOUR_TOKEN_HERE with your Discord bot's token.

Basic Callback Usage

const Discord = require("discord.js");
const { Client: Radar } = require("@yoshiboi18303/radarcord-js");

const client = new Discord.Client({
    intents: new Discord.IntentsBitField(["Guilds"]),
});
const radar = new Radar(client, "myradarcordauthtoken"); // Make sure to replace myradarcordauthtoken with your actual Radarcord auth token.
const callback = async (result) => {
    // You can also send messages to Discord if you prefer!
    console.log(result);
}

client.on("ready", async () => {
    console.log("The client is ready!");
    await radar.postWithCallback(callback);
});

client.login("YOUR_TOKEN_HERE"); // Make sure to replace YOUR_TOKEN_HERE with your Discord bot's token.

Last updated