{"id":4501,"library":"discord-webhook","title":"Discord Webhook","description":"discord-webhook is a Python library designed to easily send Discord webhooks. It simplifies the process of sending messages, embeds, files, and managing webhook interactions with Discord's API. The current version is 1.4.1, and it maintains an active development cycle with frequent updates addressing features, fixes, and occasionally breaking changes.","status":"active","version":"1.4.1","language":"python","source_language":"en","source_url":"https://github.com/lovvskillz/python-discord-webhook","tags":["discord","webhook","api","communication","bot"],"install":[{"cmd":"pip install discord-webhook","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for making HTTP requests to the Discord API.","package":"requests","optional":false}],"imports":[{"symbol":"DiscordWebhook","correct":"from discord_webhook import DiscordWebhook"},{"symbol":"DiscordEmbed","correct":"from discord_webhook import DiscordEmbed"},{"note":"For asynchronous operations, use AsyncDiscordWebhook.","symbol":"AsyncDiscordWebhook","correct":"from discord_webhook import AsyncDiscordWebhook"}],"quickstart":{"code":"import os\nfrom discord_webhook import DiscordWebhook, DiscordEmbed\n\nwebhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')\n\nif webhook_url:\n    webhook = DiscordWebhook(url=webhook_url)\n\n    # Create an embed\n    embed = DiscordEmbed(\n        title='New Event Alert',\n        description='A new event has been scheduled. Check it out!',\n        color='03b2f8' # Hex color without the #\n    )\n\n    # Add fields to the embed\n    embed.add_embed_field(name='Event Name', value='Python Dev Meetup')\n    embed.add_embed_field(name='Date', value='2025-08-01', inline=True)\n    embed.add_embed_field(name='Time', value='19:00 UTC', inline=True)\n\n    # Set footer and timestamp\n    embed.set_footer(text='Powered by discord-webhook')\n    embed.set_timestamp()\n\n    # Add the embed to the webhook\n    webhook.add_embed(embed)\n\n    # Execute the webhook\n    try:\n        response = webhook.execute()\n        print(f\"Webhook sent successfully. Status: {response.status_code}\")\n    except Exception as e:\n        print(f\"Failed to send webhook: {e}\")\nelse:\n    print(\"DISCORD_WEBHOOK_URL environment variable not set. Skipping webhook send.\")","lang":"python","description":"This quickstart demonstrates how to send a Discord webhook with an embedded message. It retrieves the webhook URL from an environment variable, constructs a `DiscordEmbed` with a title, description, color, fields, footer, and timestamp, then adds it to a `DiscordWebhook` instance and executes it. Remember to set the `DISCORD_WEBHOOK_URL` environment variable."},"warnings":[{"fix":"Ensure `url` is a single string. For `.edit()` and `.delete()`, call them without arguments after the webhook has been executed and its ID populated.","message":"In version 1.0.0, the `url` parameter for `DiscordWebhook` and `AsyncDiscordWebhook` was restricted to accept only a single URL string. Additionally, the `.edit()` and `.delete()` methods no longer accept parameters.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update calls from `del_embed_field()` to `delete_embed_field()`.","message":"Version 1.0.0 renamed `DiscordEmbed.del_embed_field()` to `DiscordEmbed.delete_embed_field()`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Remove the `remove_files` parameter from `.execute()` calls. The library now handles file clearing automatically.","message":"Version 1.1.0 removed `remove_files` as an optional parameter from the `.execute()` method. Files are now automatically cleared after execution to prevent accidental re-upload on subsequent edits.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Update any exception handling or imports of `ColourNotInRangeException` to `ColorNotInRangeException`.","message":"In version 0.17.0, `ColourNotInRangeException` was renamed to `ColorNotInRangeException` for consistency.","severity":"breaking","affected_versions":">=0.17.0"},{"fix":"Upgrade to version 1.2.1 or newer. If stuck on an older version, explicitly set `tts=False` when using `timeout` if TTS is not desired.","message":"Before version 1.2.1, using the `timeout` keyword argument could accidentally set `tts` (text-to-speech) to true due to a bug.","severity":"gotcha","affected_versions":"<1.2.1"},{"fix":"For full flexibility, ensure you are on version 1.4.0 or newer if passing strings. Otherwise, provide `datetime` objects for versions >=1.2.0, or rely on automatic timestamp generation if no argument is passed.","message":"The `set_timestamp()` method's accepted types for timestamps evolved. Version 1.2.0 added support for `datetime` objects, and 1.4.0 added support for string representations.","severity":"gotcha","affected_versions":"<1.4.0"}],"env_vars":null,"search_vec":"'1.4.1':37 'activ':42 'address':48 'api':32,57 'bot':59 'break':53 'chang':54 'communic':58 'current':34 'cycl':44 'design':10 'develop':43 'discord':1,4,14,30,55 'discord-webhook':3 'easili':12 'emb':23 'featur':49 'file':24 'fix':50 'frequent':46 'interact':28 'librari':9 'maintain':40 'manag':26 'messag':22 'occasion':52 'process':19 'python':8 'send':13,21 'simplifi':17 'updat':47 'version':35 'webhook':2,5,15,27,56","created_at":"2026-04-12T13:55:21.548214+00:00","updated_at":"2026-04-17T15:10:19.174049+00:00","problems":[{"fix":"Install the package using pip: `pip install discord-webhook`","cause":"The `discord-webhook` package is not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'discord_webhook'"},{"fix":"Verify that the webhook URL is correctly copied from Discord, is still active, and has not been deleted. Create a new webhook if necessary and update your code with the new URL.","cause":"This error is returned by Discord's API, indicating that the provided webhook URL is incorrect, expired, or the webhook itself has been deleted on Discord.","error":"{\"message\": \"Unknown Webhook\", \"code\": 10015}"},{"fix":"Ensure that your `DiscordWebhook` object or its `execute()` method includes valid `content`, `embeds`, or `files` parameters. For example, `webhook = DiscordWebhook(url='YOUR_WEBHOOK_URL', content='Your message here')`.","cause":"This HTTP status code indicates that the request sent to Discord's API was malformed or missing required parameters, such as attempting to send an empty message without any content, embeds, or files.","error":"400 Bad Request"},{"fix":"Check the webhook's permissions in Discord (ensure it can send messages in the channel). If rate-limited, the library's `rate_limit_retry=True` (default) should handle it, but excessive requests might still lead to this. Verify the webhook URL again for any errors.","cause":"This HTTP status code typically means the webhook lacks the necessary permissions to post in the specified channel, is being rate-limited by Discord, or the webhook token/URL is invalid or unauthorized.","error":"403 Forbidden"},{"fix":"Add the `DiscordEmbed` object to the `DiscordWebhook` object using `add_embed()` and then call `execute()` on the `DiscordWebhook` object.","cause":"The `send()` or `execute()` method belongs to the `DiscordWebhook` object, not the `DiscordEmbed` object. Embeds must be added to a webhook object before the webhook can be sent.","error":"AttributeError: 'DiscordEmbed' object has no attribute 'send'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/lovvskillz/python-discord-webhook","docs":null,"changelog":null,"pypi":"https://pypi.org/project/discord-webhook/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}