Python SDK for Commandless relay API
Project description
commandless-relay (Python)
Official Python SDK for the Commandless relay API.
This package gives Python bots a simple client and a ready-to-use discord.py adapter.
Install
Core client:
pip install commandless-relay
With discord.py adapter support:
pip install "commandless-relay[discord]"
AI-only setup (no code)
Install and run from terminal, similar to the Node SDK flow:
pip install "commandless-relay[discord]"
commandless-discord
Set these environment variables first:
BOT_TOKEN- your Discord bot tokenCOMMANDLESS_API_KEY- API key created in Commandless dashboardCOMMANDLESS_SERVICE_URL(orSERVICE_URL) - optional, defaults to Commandless backendBOT_ID- optional bot ID from dashboard (recommended)COMMANDLESS_HMAC_SECRET- optional HMAC secretCOMMANDLESS_MENTION_REQUIRED- optional (trueby default)COMMANDLESS_RUNTIME_MODE- optional (sdkdefault, usesdk_hostedfor always-on hosted connectors)
Quickstart (discord.py in code)
import os
import discord
from commandless_relay import RelayClient, use_discord_adapter
TOKEN = os.getenv("BOT_TOKEN")
API_KEY = os.getenv("COMMANDLESS_API_KEY")
BASE_URL = os.getenv("COMMANDLESS_SERVICE_URL") or os.getenv("SERVICE_URL") # optional
intents = discord.Intents.default()
intents.message_content = True
intents.messages = True
intents.guilds = True
client = discord.Client(intents=intents)
relay = RelayClient(api_key=API_KEY, base_url=BASE_URL) # base_url optional
use_discord_adapter(client, relay, mention_required=True)
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
client.run(TOKEN)
Environment variables
BOT_TOKEN- your Discord bot tokenCOMMANDLESS_API_KEY- API key created in Commandless dashboardCOMMANDLESS_SERVICE_URL(orSERVICE_URL) - optional, defaults to Commandless backendBOT_ID- optional fixed bot id to lock config/personaCOMMANDLESS_HMAC_SECRET- optional HMAC secretCOMMANDLESS_MENTION_REQUIRED- optional (trueby default)COMMANDLESS_DISABLE_CONFIG_CACHE- optional (falseby default)COMMANDLESS_DEBUG- optional verbose logs (falseby default)COMMANDLESS_RUNTIME_MODE- optional (sdkdefault, usesdk_hostedfor always-on hosted connectors)
Included components
RelayClientsend_event(event)-> Decision dict orNoneregister_bot(...)-> botId (optional flow)heartbeat()(optional flow)
ConfigCache- fetches
/v1/relay/config - local filtering for channel/user/role/premium/rate limits
- polls every 30 seconds
- fetches
use_discord_adapter(client, relay, mention_required=True, execute=None)- binds an
on_messagelistener - binds an
on_interactionlistener for slash commands - sends events to relay
- executes reply actions by default
- applies local config filtering by default (disable via
COMMANDLESS_DISABLE_CONFIG_CACHE=true) - sends a clear message on billing rejection (402 / no subscription or credits)
- binds an
Testing
Run unit tests:
python -m unittest discover -s tests -p "test_*.py"
Release
Use the bundled release helper:
bash scripts/release.sh
This script runs tests, builds distributions, and uploads with Twine.
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 commandless_relay-0.1.11.tar.gz.
File metadata
- Download URL: commandless_relay-0.1.11.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b7b739d5116dca56e62beff287c8088cd7fb49608210d542ce376cf6d4a2673
|
|
| MD5 |
016873bb3c45b65b890f02d669624a0c
|
|
| BLAKE2b-256 |
9b69ba743cff139576c5969e70681269b0fffe7973918952a447ffe48c291036
|
File details
Details for the file commandless_relay-0.1.11-py3-none-any.whl.
File metadata
- Download URL: commandless_relay-0.1.11-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61ce092e639b648e9a875f10f6b09d0f91483ed9dd8e4d01cd5767f20d6edce0
|
|
| MD5 |
022cd423e096cee6ceb462797341a309
|
|
| BLAKE2b-256 |
e8f9f44c6c2b869a260ef10293084589c99a734eceae755d85949fab9c2d4dea
|