Librairies clients
Un seul fichier par langage :
User · Bot · EmbedBuilder
· ActionRow / Button / WebAction (tous langages).
BobCord API : …
Authorization: Bearer <token>.
Même API REST pour tous les SDKs (py/js/ts + rust/cs/go/dart/swift/fs/kt/java/php).
Python
3.9+ · requests + websocket-client
pip install requests websocket-client from bobcord_lib import Bot, EmbedBuilder, ActionRow, Button, WebAction
User(token)· selfbotBot(token)·@bot.command/@bot.eventEmbedBuilder()·Builder()ActionRow·Button·WebAction· selects
JavaScript vanilla
Navigateur / Node 18+ (fetch natif)
import { Bot, EmbedBuilder } from './bobcord.js'
new User(token)· selfbotnew Bot(token)·.command()/.event()new EmbedBuilder()·new Builder()ActionRow·Button·WebAction· selects
TypeScript
Bun ou Node (tsx)
bun run bobcord.ts # ou: npx tsx bobcord.ts
- mêmes classes, typées
Context·Author·BobEventActionRow·Button·WebAction
Rust
tokio + reqwest + serde_json
let bot = Bot::new("TOKEN");
bot.send("salut", "général", None).await?;
Bot::new(token)·login/sendEmbedBuilder·ActionRow·Button·WebAction
C#
.NET 6+ · HttpClient + System.Text.Json
var bot = new Bot("TOKEN");
await bot.SendAsync("salut", actionRows: new[]{ row });
new Bot(token)·SendAsync/LoginAsyncEmbedBuilder·ActionRow·Button·WebAction
Go
stdlib net/http + encoding/json
bot := NewBot("TOKEN")
bot.Send("salut", "général", &SendOpts{ActionRows: rows})
NewBot(token)·Send/LoginActionRow·ButtonWebAction·WebActionConfirm
Dart
http package
final bot = Bot('TOKEN');
await bot.send('salut', actionRows: rows);
command/event/startEmbedBuilder().title().build()ActionRow·Button·WebAction· selects
Swift
URLSession (REST)
let bot = Bot("TOKEN")
bot.send("salut", actionRows: rows) { _ in }
command/event/startEmbedBuilder().title().build()ActionRow·Button·WebAction· selects
F#
.NET · HttpClient + System.Text.Json
let bot = Bot()
bot.Login("TOKEN")
bot.Start().Wait()
Command/Event/StartEmbedBuilder().Title(...).Build()ActionRow·Button·WebAction· selects
Kotlin
OkHttp + org.json (REST)
val bot = Bot()
bot.login("TOKEN")
bot.start()
command/event/startEmbedBuilder().title().build()ActionRow·Button·WebAction· selects
Java
HttpClient + org.json (REST)
Bot bot = new Bot();
bot.login("TOKEN");
bot.start();
command/event/startnew EmbedBuilder().title().build()ActionRow·Button·WebAction· selects
PHP
PHP 8+ · stream_socket (WS maison)
$bot = new Bot();
$bot->login('TOKEN');
$bot->start();
command/event/start(new EmbedBuilder())->title()->build()ActionRow·Button·WebAction· selects
Surface API
User / Bot login() send() edit() delete() react() getMessage() getUser() run()/start() Bot only @bot.event / bot.event() → ready, message, … @bot.command / bot.command() → !ping etc. EmbedBuilder().title().description().color().field().footer().build() Builder().set(k, v).build() → dict générique
Snippets
Exemples prêts à coller. Token BobCord depuis /applications · token Discord bot pour Rust/C#/Go/etc.
Python — Bot + embed
Fichier : bobcord_lib.py
from bobcord_lib import Bot, EmbedBuilder
bot = Bot("TON_TOKEN_24_CHARS")
@bot.event
def on_ready():
print("prêt:", bot.user)
@bot.command("ping")
def ping(ctx):
emb = (EmbedBuilder()
.title("Pong")
.description(f"salut {ctx.author.displayname}")
.color(0x5B8CFF)
.build())
ctx.reply(embeds=[emb])
bot.run()
JavaScript — Bot + embed
Fichier : bobcord.js
import { Bot, EmbedBuilder } from './bobcord.js';
const bot = new Bot('TON_TOKEN_24_CHARS');
bot.event('ready', () => console.log('prêt:', bot.user));
bot.command('ping', async (ctx) => {
const emb = new EmbedBuilder()
.title('Pong')
.description(`salut ${ctx.author.displayname}`)
.color(0x5b8cff)
.build();
await ctx.reply('', { embeds: [emb] });
});
bot.run();
TypeScript — Bot + embed
Fichier : bobcord.ts
import { Bot, EmbedBuilder } from './bobcord.ts';
const bot = new Bot(process.env.BOBCORD_TOKEN || 'TON_TOKEN_24_CHARS');
bot.event('ready', () => console.log('prêt:', bot.user));
bot.command('ping', async (ctx) => {
const emb = new EmbedBuilder()
.title('Pong')
.description(`salut ${ctx.author.displayname}`)
.color(0x5b8cff)
.build();
await ctx.reply('', { embeds: [emb] });
});
bot.run();
Rust — Bot + embed
Fichier : bobcord_rust.rs · deps: tokio, reqwest, serde_json
// colle bobcord_rust.rs — deps: tokio, reqwest, serde_json
use bobcord_rust::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let bot = Bot::new(std::env::var("BOBCORD_TOKEN").unwrap_or_else(|_| "TON_TOKEN".into()));
let rows = action_rows(vec![ActionRow::new(vec![
Button::web_action("Popup", "wa_c", WebAction::confirm("Sûr ?", "popup custom", None)),
Button::web_action("Réagir", "wa_r", WebAction::react("👍", "self", None)),
])]);
bot.send("test WEB_ACTION", "général", Some(SendOpts {
action_rows: Some(rows),
..Default::default()
})).await?;
Ok(())
}
C# — Bot + embed
Fichier : bobcord_cs.cs
// ajoute bobcord_cs.cs à ton projet, puis :
var bot = new Bot();
bot.Login(Environment.GetEnvironmentVariable("BOBCORD_TOKEN") ?? "TON_TOKEN");
bot.Event("ready", _ => Console.WriteLine("prêt"));
bot.Command("ping", msg =>
{
var author = msg.TryGetProperty("author", out var a) && a.TryGetProperty("username", out var u)
? u.GetString() : "?";
var emb = new EmbedBuilder()
.Title("Pong")
.Description($"salut {author}")
.Color(0x5B8CFF)
.Build();
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(emb));
});
await bot.Start();
Go — Bot + embed
Fichier : bobcord_go.go · stdlib net/http
package main
import (
"fmt"
"os"
)
func main() {
bot := NewBot()
token := os.Getenv("BOBCORD_TOKEN")
if token == "" {
token = "TON_TOKEN"
}
bot.Login(token)
bot.Event("ready", func(ev map[string]any) {
fmt.Println("prêt")
})
bot.Command("ping", func(msg map[string]any) {
author := "?"
if a, ok := msg["author"].(map[string]any); ok {
if u, ok := a["username"].(string); ok {
author = u
}
}
emb := NewEmbedBuilder().
Title("Pong").
Description("salut " + author).
Color(0x5B8CFF).
Build()
fmt.Println(emb)
})
if err := bot.Start(); err != nil {
panic(err)
}
}
Dart — Bot + embed
Fichier : bobcord_dart.dart · dep http package
import 'bobcord_dart.dart'; // ou colle le fichier unique
Future<void> main() async {
final bot = Bot();
bot.login(String.fromEnvironment('BOBCORD_TOKEN', defaultValue: 'TON_TOKEN'));
bot.event('ready', (_) => print('prêt'));
bot.command('ping', (msg) {
final author = (msg['author'] as Map?)?['username'] ?? '?';
final emb = EmbedBuilder()
.title('Pong')
.description('salut $author')
.color(0x5B8CFF)
.build();
print(emb);
});
await bot.start();
}
Swift — Bot + embed
Fichier : bobcord_swift.swift
let bot = Bot()
bot.login(ProcessInfo.processInfo.environment["BOBCORD_TOKEN"] ?? "TON_TOKEN")
bot.event("ready") { _ in
print("prêt")
}
bot.command("ping") { msg in
let author = ((msg["author"] as? [String: Any])?["username"] as? String) ?? "?"
let emb = EmbedBuilder()
.title("Pong")
.description("salut \(author)")
.color(0x5B8CFF)
.build()
print(emb)
}
bot.start()
RunLoop.main.run()
F# — Bot + embed
Fichier : bobcord_fs.fs
open System
let bot = Bot()
bot.Login(match Environment.GetEnvironmentVariable("BOBCORD_TOKEN") with null | "" -> "TON_TOKEN" | t -> t)
bot.Event("ready", fun _ -> printfn "prêt")
bot.Command("ping", fun msg ->
let mutable author = "?"
let mutable a = Unchecked.defaultof<_>
if msg.TryGetProperty("author", &a) then
let mutable u = Unchecked.defaultof<_>
if a.TryGetProperty("username", &u) then author <- u.GetString()
let emb =
EmbedBuilder()
.Title("Pong")
.Description($"salut {author}")
.Color(0x5B8CFF)
.Build()
printfn "%A" emb
)
bot.Start().Wait()
Kotlin — Bot + embed
Fichier : bobcord_kt.kt · OkHttp + org.json
fun main() {
val bot = Bot()
bot.login(System.getenv("BOBCORD_TOKEN") ?: "TON_TOKEN")
bot.event("ready") { println("prêt") }
bot.command("ping") { msg ->
val author = msg.optJSONObject("author")?.optString("username") ?: "?"
val emb = EmbedBuilder()
.title("Pong")
.description("salut $author")
.color(0x5B8CFF)
.build()
println(emb)
}
bot.start()
}
Java — Bot + embed
Fichier : bobcord_java.java
public class Main {
public static void main(String[] args) throws Exception {
Bot bot = new Bot();
String token = System.getenv("BOBCORD_TOKEN");
bot.login(token != null ? token : "TON_TOKEN");
bot.event("ready", ev -> System.out.println("prêt"));
bot.command("ping", msg -> {
String author = "?";
if (msg.optJSONObject("author") != null) {
author = msg.optJSONObject("author").optString("username", "?");
}
var emb = new EmbedBuilder()
.title("Pong")
.description("salut " + author)
.color(0x5B8CFF)
.build();
System.out.println(emb);
});
bot.start();
}
}
PHP — Bot + embed
Fichier : bobcord_php.php
<?php
require 'bobcord_php.php';
$bot = new Bot();
$bot->login(getenv('BOBCORD_TOKEN') ?: 'TON_TOKEN');
$bot->event('ready', fn($e) => print("prêt\\n"));
$bot->command('ping', function ($msg) {
$author = $msg['author']['username'] ?? '?';
$emb = (new EmbedBuilder())
->title('Pong')
->description("salut $author")
->color(0x5B8CFF)
->build();
print_r($emb);
// envoi REST channel_id + token à brancher côté app
});
$bot->start();