{"id":9656,"library":"dhooks-lite","title":"dhooks-lite","description":"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.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/ErikKalkoken/dhooks-lite","tags":["discord","webhook","api","messaging"],"install":[{"cmd":"pip install dhooks-lite","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Handles HTTP requests to the Discord API.","package":"requests","optional":false}],"imports":[{"note":"Users coming from the original 'dhooks' library might mistakenly use its import path. dhooks-lite is a separate package.","wrong":"from dhooks import Webhook","symbol":"Webhook","correct":"from dhooks_lite import Webhook"}],"quickstart":{"code":"import os\nfrom dhooks_lite import Webhook\n\n# It's recommended to use an environment variable for security.\n# Replace with your actual webhook URL or set DISCORD_WEBHOOK_URL in your environment.\nwebhook_url = os.environ.get(\n    \"DISCORD_WEBHOOK_URL\",\n    \"https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN\" # Placeholder, replace with your actual URL\n)\n\nif \"YOUR_ID\" in webhook_url:\n    print(\"Warning: Please replace the placeholder webhook URL or set DISCORD_WEBHOOK_URL environment variable.\")\n    # For demonstration, we'll proceed, but real use requires a valid URL.\n\ntry:\n    webhook = Webhook(webhook_url)\n\n    # 1. Send a simple text message\n    webhook.send(\"Hello from `dhooks-lite`! This is a simple message.\")\n    print(\"Sent simple message.\")\n\n    # 2. Send a message with an embed (embeds must be dicts conforming to Discord API)\n    embed_data = {\n        \"title\": \"dhooks-lite Embed Example\",\n        \"description\": \"This embed demonstrates sending structured data.\",\n        \"color\": 0x3498DB, # Hex color code (e.g., Discord's blurple)\n        \"fields\": [\n            {\"name\": \"Feature 1\", \"value\": \"Lightweight\", \"inline\": True},\n            {\"name\": \"Feature 2\", \"value\": \"Easy to Use\", \"inline\": True}\n        ],\n        \"footer\": {\"text\": \"Powered by dhooks-lite\"},\n        \"timestamp\": \"2023-10-27T10:00:00.000Z\" # ISO 8601 timestamp\n    }\n    webhook.send(embeds=[embed_data])\n    print(\"Sent message with embed.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your Discord webhook URL is valid and active.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Consult the `dhooks-lite` GitHub README for its specific feature set and API usage. Do not assume `dhooks` examples will work directly.","message":"dhooks-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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always provide embeds as dictionaries (e.g., `webhook.send(embeds=[{'title': '...', 'description': '...'}])`). Refer to Discord's API documentation for the correct embed structure.","message":"Unlike 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Providing 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure your webhook URL starts with `https://discord.com/api/webhooks/...`.","cause":"The provided webhook URL is missing the 'http://' or 'https://' scheme prefix.","error":"requests.exceptions.MissingSchema: Invalid URL \"your_webhook_url\": No schema supplied. Perhaps you meant https://your_webhook_url?"},{"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.","cause":"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.","error":"dhooks_lite.webhook.WebhookException: (400) Bad Request"},{"fix":"Change your import statement to `from dhooks_lite import Webhook`.","cause":"You are trying to import `Webhook` from the original `dhooks` library while intending to use `dhooks-lite`. These are separate packages.","error":"AttributeError: module 'dhooks' has no attribute 'Webhook'"}]}