Registry / communication / dhooks-lite

dhooks-lite

JSON →
library1.1.0pypypi✓ verified 86d ago

dhooks-lite is a lightweight Python wrapper for interacting with Discord webhooks, focusing on essential functionality for sending messages and embeds. It provides a simpler alternative to the original `dhooks` library. The current version is 1.1.0, and it has a moderate release cadence, with the last update in mid-2023.

pip install dhooks-lite
INSTALL
IMPORT
SIG · DHOOKS-LITE
D
dhooks-lite
communicationpythonv1.1.0
Install
2.1s avg
Import
591ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.621s · 21.3MB
glibc
py 3.103.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.")
Debug
Known issues
gotchadhooks-lite is a separate and 'lite' version of the original `dhooks` library. It does not provide all features or the exact same API as `dhooks`. Be aware of potential API differences if migrating or expecting full feature parity.
fix
Consult the `dhooks-lite` GitHub README for its specific feature set and API usage. Do not assume `dhooks` examples will work directly.
affects: All versions
gotchaUnlike some other Discord libraries (e.g., `discord.py` or the full `dhooks`), `dhooks-lite` does not include a dedicated `Embed` class. When sending embeds, you must construct a Python dictionary that strictly conforms to Discord's Embed Object API specification.
fix
Always provide embeds as dictionaries (e.g., `webhook.send(embeds=[{'title': '...', 'description': '...'}])`). Refer to Discord's API documentation for the correct embed structure.
affects: All versions
gotchaProviding an invalid or expired Discord webhook URL will lead to errors. Common issues include HTTP 400 (Bad Request), 404 (Not Found), or network connection errors.
fix
Double-check your webhook URL for correctness, ensure it hasn't been deleted or revoked in Discord, and that your Discord server or channel settings aren't blocking it. Handle `WebhookException` or `requests.exceptions` gracefully.
affects: All versions
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.
fix
Ensure 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.
fix
Review 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.
fix
Change 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.
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
dhooks-lite — pip install dhooks-lite · libregistry