Radarcord-js
The best way to interact with the Radarcord API!
Features
Easy to use
Supports
discord.js
and will supporteris
soon.Supports TypeScript
May come with Webhook support soon.
Installation
npm install @yoshiboi18303/radarcord-js
yarn add @yoshiboi18303/radarcord-js
pnpm add @yoshiboi18303/radarcord-js
Basic discord.js
Usage
discord.js
Usageconst 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.
import Discord from "discord.js";
import { Client as Radar } from "@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
eris
UsageThis usage also works for classes that extend the Eris.Client
class (e.g. Eris.CommandClient
) so don't worry about having to rewrite your whole codebase!
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();
import Eris from "eris";
// Note that we're importing ErisClient here rather than Client.
import { ErisClient as Radar } from "@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.
import Discord from "discord.js";
import { Client as Radar } from "@yoshiboi18303/radarcord-js";
import { TimeoutInterval } from "@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 */, TimeoutInterval.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.
import Discord from "discord.js";
import { Client as Radar } from "@yoshiboi18303/radarcord-js";
import { StatsPostCallback } from "@yoshiboi18303/radarcord-js/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.
const callback: StatsPostCallback = 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