Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.621s · 21.3MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.1s · import 0.560s · 22MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Webhook
✓ from dhooks_lite import Webhook
✗ from dhooks import Webhook
Users coming from the original 'dhooks' library might mistakenly use its import path. dhooks-lite is a separate package.
This quickstart demonstrates how to initialize a `Webhook` object and send both a simple text message and a more complex message containing a Discord-API-compliant embed dictionary.
import os
from dhooks_lite import Webhook
# It's recommended to use an environment variable for security.
# Replace with your actual webhook URL or set DISCORD_WEBHOOK_URL in your environment.
webhook_url = os.environ.get(
"DISCORD_WEBHOOK_URL",
"https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN" # Placeholder, replace with your actual URL
)
if "YOUR_ID" in webhook_url:
print("Warning: Please replace the placeholder webhook URL or set DISCORD_WEBHOOK_URL environment variable.")
# For demonstration, we'll proceed, but real use requires a valid URL.
try:
webhook = Webhook(webhook_url)
# 1. Send a simple text message
webhook.send("Hello from `dhooks-lite`! This is a simple message.")
print("Sent simple message.")
# 2. Send a message with an embed (embeds must be dicts conforming to Discord API)
embed_data = {
"title": "dhooks-lite Embed Example",
"description": "This embed demonstrates sending structured data.",
"color": 0x3498DB, # Hex color code (e.g., Discord's blurple)
"fields": [
{"name": "Feature 1", "value": "Lightweight", "inline": True},
{"name": "Feature 2", "value": "Easy to Use", "inline": True}
],
"footer": {"text": "Powered by dhooks-lite"},
"timestamp": "2023-10-27T10:00:00.000Z" # ISO 8601 timestamp
}
webhook.send(embeds=[embed_data])
print("Sent message with embed.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your Discord webhook URL is valid and active.")
Errors
Common errors & fixes
requests.exceptions.MissingSchema: Invalid URL "your_webhook_url": No schema supplied. Perhaps you meant https://your_webhook_url?
The provided webhook URL is missing the 'http://' or 'https://' scheme prefix.
fixEnsure your webhook URL starts with `https://discord.com/api/webhooks/...`.
dhooks_lite.webhook.WebhookException: (400) Bad Request
This error typically indicates that the payload sent to Discord (message content, embeds, etc.) is malformed or violates Discord's API rules. It could also mean the webhook token is incorrect.
fixReview your `send()` arguments, especially any embed dictionaries, to ensure they adhere to Discord's API specifications. Verify the webhook URL and token are correct.
AttributeError: module 'dhooks' has no attribute 'Webhook'
You are trying to import `Webhook` from the original `dhooks` library while intending to use `dhooks-lite`. These are separate packages.
fixChange your import statement to `from dhooks_lite import Webhook`.
Upgrade
Version history
1.1.0latest on PyPI · released Jul 16, 2023
Audit
Dependencies
requestsrequiredHandles HTTP requests to the Discord API.