JavaScript / TypeScript
Node.js
const { Client, GatewayIntentBits } = require('discord.js');
const { BotillonClient } = require('@botillon/sdk');
const discord = new Client({ intents: [GatewayIntentBits.Guilds] });
const botillon = new BotillonClient({
token: process.env.BOTILLON_TOKEN,
discordClient: discord,
debug: true,
});
botillon.on('error', (error) => {
console.warn('Botillon [' + error.code + '] : ' + error.message);
});
discord.login(process.env.DISCORD_TOKEN);Le premier envoi part à la connexion, puis toutes les 5 minutes. Les commandes et le profil sont vérifiés toutes les heures et après un changement détecté.
Python
Python
import os
from botillon_sdk import BotillonClient
botillon = BotillonClient(token=os.environ["BOTILLON_TOKEN"])
# discord.py : le provider est appelé à chaque envoi.
botillon.set_stats_provider(lambda: {
"server_count": len(bot.guilds),
"shard_count": getattr(bot, "shard_count", None),
})
botillon.on("error", lambda error: print(f"Botillon [{error.code}] {error.message}"))
botillon.start()Rust
Rust
use botillon_sdk::{BotillonClient, Stats};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = BotillonClient::new(std::env::var("BOTILLON_TOKEN")?);
let stats = Stats {
server_count: 1234,
shard_count: Some(1),
shards: None,
user_count: None,
};
let result = client.post_stats(&stats)?;
println!("{} serveurs, en ligne: {}", result.server_count, result.online);
Ok(())
}Go
Go
package main
import (
"context"
"os"
botillon "github.com/Botillon/botillon/sdk/go"
)
func main() {
client := botillon.New(os.Getenv("BOTILLON_TOKEN"))
_, err := client.PostStats(context.Background(), botillon.Stats{
ServerCount: 1234,
})
if err != nil { panic(err) }
}C
C
#include "botillon.h"
int main(void) {
botillon_client bot;
if (botillon_init(&bot, getenv("BOTILLON_TOKEN"), NULL) != 0) return 1;
int status = botillon_post_stats(&bot, 1234, 1, 0, NULL);
if (status != 200) fprintf(stderr, "Botillon: %s\n", bot.last_error);
botillon_free(&bot);
return status == 200 ? 0 : 1;
}curl / HTTP
curl
export BOTILLON_TOKEN="blp_..."
curl -sS https://botillon.fr/api/v1/me/runtime/stats \
-H "Authorization: Bearer $BOTILLON_TOKEN" \
-H "Content-Type: application/json" \
-H "User-Agent: BotillonSDK/curl/0.1.0" \
-d '{"server_count": 1234, "shard_count": 1}'