{"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":"en","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,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}