Libraries

A list of available libraries to connect your bot to Statcord.
Python
JavaScript
Python

Installation

python3 -m pip install statcord.py

from discord.ext import commands
import statcord
class StatcordPost(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.key = "statcord.com-ADDYOURKEYHERE"
self.api = statcord.Client(self.bot,self.key)
self.api.start_loop()
@commands.Cog.listener()
async def on_command(self,ctx):
self.api.command_run(ctx)
def setup(bot):
bot.add_cog(StatcordPost(bot))
JavaScript

Installation - Standard Discord Bot. For more documentation, click the link at the bottom of the page.

npm i statcord.js

const Statcord = require("statcord.js");
const Discord = require("discord.js");
const client = new Discord.Client();
// Create statcord client
const statcord = new Statcord.Client("statcord.com-APIKEY", client);
// Client prefix
const prefix = "cs!";
client.on("ready", async () => {
console.log("ready");
// Start auto posting
let initalPost = await statcord.autopost();
// If there is an error, console.error and exit
if (initalPost) {
console.error(initalPost);
process.exit();
}
});
client.on("message", async (message) => {
if (message.author.bot) return;
if (message.channel.type !== "text") return;
if (!message.content.startsWith(prefix)) return;
let command = message.content.split(" ")[0].toLowerCase().substr(prefix.length);
// Post command
statcord.postCommand(command, message.author.id);
if (command == "say") {
message.channel.send("say");
} else if (command == "help") {
message.channel.send("help");
} else if (command == "post") {
// Only owner runs this command
if (message.author.id !== "bot_owner_id") return;
// Example of manual posting
let postError = await statcord.post();
// If there is a post error notify command runner
if (postError) {
message.channel.send(postError.message);
}
}
})
client.login("TOKEN");

Contribute

Contributions are always welcome! You can contact us on Discord to get your library added to the docs.