SDK officiel Python pour synchroniser les statistiques de votre bot Discord avec DiscordPlace
Project description
DiscordPlace Sync — Python SDK
SDK Python officiel pour synchroniser automatiquement les statistiques de votre bot Discord avec discordplace.com.
Port Python du package npm
discordplace-sync. Compatible avec discord.py, disnake, py-cord et nextcord.
Installation
pip install discordplace-sync
Python ≥ 3.8 requis.
Quickstart (discord.py)
import discord
from discord.ext import commands
from discordplace_sync import DiscordPlaceSDK
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
sdk = DiscordPlaceSDK(
api_key="dpsk_xxxxx", # disponible dans le dashboard de votre bot
bot_id="123456789012345678",
auto_sync=True, # ré-envoie les stats toutes les 5 min
sync_interval=300, # secondes
debug=False,
)
@bot.event
async def on_ready():
await sdk.start()
await sdk.auto_collect_stats(bot) # collecte guildCount/userCount/latency/uptime
await sdk.sync_bot_info(bot) # envoie aussi les commandes slash + prefix
bot.run("BOT_TOKEN")
Quickstart (disnake / nextcord / py-cord)
import disnake
from disnake.ext import commands
from discordplace_sync import DiscordPlaceSDK
bot = commands.Bot(command_prefix="!", intents=disnake.Intents.default())
sdk = DiscordPlaceSDK(api_key="dpsk_xxxxx", bot_id="123456789012345678")
@bot.event
async def on_ready():
await sdk.start()
await sdk.auto_collect_stats(bot)
await sdk.sync_bot_info(bot, treat_all_as_hybrid=True)
bot.run("BOT_TOKEN")
API
DiscordPlaceSDK(api_key, bot_id, **options)
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | Clé API du bot |
bot_id |
str |
required | ID Discord du bot |
endpoint |
str |
https://discordplace.com/api |
Base URL de l'API |
auto_sync |
bool |
False |
Active la boucle automatique |
sync_interval |
float |
300 |
Secondes entre chaque sync auto |
timeout |
float |
10 |
Timeout HTTP |
retries |
int |
3 |
Tentatives sur erreur retryable |
debug |
bool |
False |
Active les logs DEBUG |
Méthodes async
await sdk.start()— démarre le SDK (et la boucle auto si activée).await sdk.stop()— arrête le SDK et ferme la session HTTP.await sdk.update_stats({"guildCount": 42, ...})— envoie un payload de stats.await sdk.post_stats(...)— alias rétro-compatible.await sdk.get_stats(period="24h")— récupère l'historique.await sdk.get_api_key_info()— infos sur la clé API.await sdk.check_sync_status()— état de synchronisation.await sdk.auto_collect_stats(client)— collecte auto + envoi.await sdk.sync_bot_info(client, treat_all_as_hybrid=False, prefix_only_commands=[], slash_only_commands=[])— synchronise infos + commandes.
Événements
sdk.on("success", lambda payload: print("✅ Stats envoyées:", payload))
sdk.on("error", lambda err: print("❌ Erreur:", err))
sdk.on("sync_success", lambda r: print("🔄 Sync info:", r))
Évènements disponibles : start, stop, success, error, sync_success, force_sync_detected, force_sync_completed. Les callbacks peuvent être sync ou async.
Context manager
async with DiscordPlaceSDK(api_key="...", bot_id="...") as sdk:
await sdk.update_stats({"guildCount": 10})
Champs de stats acceptés
guildCount (requis), userCount, channelCount, commandsUsed, uptime (ms), memoryUsage (MB), latency (ms), version, isOnline. Les noms snake_case sont aussi acceptés (guild_count, user_count, …).
Licence
MIT © DiscordPlace Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discordplace_sync-1.0.0.tar.gz.
File metadata
- Download URL: discordplace_sync-1.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b80b377b9a896cb6fb480df81b7e2b04a9c9b60479ccc67516c42dc8c85764
|
|
| MD5 |
7b59e279ecfc6fd10390b775464121e9
|
|
| BLAKE2b-256 |
f7bfed0d923b830f515cf95aac568cc2bafabb1ce5a8d34b65560b021ca71c80
|
File details
Details for the file discordplace_sync-1.0.0-py3-none-any.whl.
File metadata
- Download URL: discordplace_sync-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27480f55a69ade5f819b63e5d3105848a24be09292d804182df8b9aa6e3f30e5
|
|
| MD5 |
5bbf5b416744545745d9fcb51b99ebb3
|
|
| BLAKE2b-256 |
26929117c6f9a980601ec56d20baf474acf58a7027855f5dd7fc380b2c368254
|