Easy to use API wrapper for DiscordBotList in Python
Project description
discordbotlist.py
Easy to use API wrapper for DiscordBotList in Python
Installation
[!WARNING] You need to install an optional package either discordbotlist-py[pycord] or discordbotlist-py[discord]
# For discord.py
pip install discordbotlist-py[discord]
# For py-cord
pip install discordbotlist-py[pycord]
Usage
discord.py usage
import discord
from discordbotlist import DblClient
from discord import Intents, Client
from discord import app_commands
class MyClient(Client):
def __init__(self, *, intents: Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
await self.tree.sync()
bot = MyClient(intents=Intents.all())
# Initialize the DBL client with your API token
dbl = DblClient("your_dbl_token_here", bot)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
# Start auto-posting stats every hour (3600 seconds)
dbl.start_posting(interval=3600)
# Post commands to DiscordBotList
commands = await bot.tree.fetch_commands()
command_list = [
{
"name": cmd.name,
"description": cmd.description,
"type": cmd.type.value
}
for cmd in commands
]
await dbl.post_command(command_list)
print(f"Posted {len(command_list)} commands to DiscordBotList.")
# Listen for DBL stats updates
@dbl.event
async def on_dbl_updated(payload):
print(f"DiscordBotList stats updated: {payload}")
# Listen for DBL commands updates
@dbl.event
async def on_dbl_commands_updated(commands):
print(f"DiscordBotList commands updated: {commands}")
bot.run("your_bot_token_here")
py-cord usage
discord.py usage
import discord
from discordbotlist import DblClient, AppCommandPayload
from discord import Intents, Bot
bot = Bot(intents=Intents.all())
# Initialize the DBL client with your API token
dbl = DblClient("your_dbl_token_here", bot)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
# Start auto-posting stats every hour (3600 seconds)
dbl.start_posting(interval=3600)
# Post commands to DiscordBotList
commands = bot.application_commands
command_list = [
AppCommandPayload(
name=cmd.name, description=cmd.description, type=1
)
for cmd in commands
]
await dbl.post_command(command_list)
print(f"Posted {len(command_list)} commands to DiscordBotList.")
# Listen for DBL stats updates
@dbl.event
async def on_dbl_updated(payload):
print(f"DiscordBotList stats updated: {payload}")
# Listen for DBL commands updates
@dbl.event
async def on_dbl_commands_updated(commands):
print(f"DiscordBotList commands updated: {commands}")
bot.run("your_bot_token_here")
Manual Stats Posting
# Manually post stats
await dbl.post_status()
Stop Auto-posting
# Stop the auto-posting loop
await dbl.stop_posting()
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 discordbotlist_py-1.0.1.tar.gz.
File metadata
- Download URL: discordbotlist_py-1.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc8244d00de4f8ebfb7813daee85346fb56f946df96de1051bad1322a447e9ea
|
|
| MD5 |
9d60fed635fe2e8480b6e9891ab3197b
|
|
| BLAKE2b-256 |
2160e852b59c0dc037c28fa9ca9369d44a8874888f18c6748e79070da450876b
|
File details
Details for the file discordbotlist_py-1.0.1-py3-none-any.whl.
File metadata
- Download URL: discordbotlist_py-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a1139f679609d81d77ef7a02d658b2fbc76c1dd9109aac79cf68e73b988bc87
|
|
| MD5 |
3bd2b8bb669571a183e6a86e9e65ece0
|
|
| BLAKE2b-256 |
a48f2843504d2dee49e434dd07b3dc131978e9b077490604b4bd03c5f8b9dcd1
|