A simple Discord webhook wrapper for Python
Project description
Cordhook
Cordhook is a clean, lightweight Python wrapper around the Discord Webhook API.
It provides a developer-friendly way to send rich messages, embeds, and file attachments with built-in validation, retry logic, and error handling.
Features
- Simple interface for sending messages and embeds
- Full support for Discord embed customization
- File attachment support
- Auto retry logic with exponential backoff
- Custom exception handling for common issues
- Utility functions for formatting, truncating, and validating payloads
Quick Start
pip install cordhook
from cordhook import Webhook
wh = Webhook("https://discord.com/api/webhooks/...")
wh.set_content("Hello, world!")\\
.add_embed("Embed Title", "This is a test")\\
.send()
Embed Creation
You can use the create_embed() helper for more control:
from cordhook import create_embed
embed = create_embed(
title="Sample Embed",
description="Generated with Cordhook",
footer_text="Sent via Python",
timestamp=True
)
Utilities
- retry_request(func, retries=3) – retries any function with optional backoff
- validate_url(url) – checks if a webhook URL is valid
- json_pretty_print(obj) – nicely formats any JSON or dict
- truncate_text(text, limit=1024) – prevents hitting Discord text limits
Exceptions
Cordhook raises specific exceptions so you can catch and handle errors cleanly:
- WebhookException
- InvalidPayloadException
- RateLimitException
- FileAttachmentException
Example with File
Webhook("url")
.set_content("With a file!")
.attach_file("cat.png")
.send()
License
MIT License — free to use, modify, and distribute
Feedback or Contributions
Open an issue or PR to suggest improvements or fix bugs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cordhook-1.0.tar.gz.
File metadata
- Download URL: cordhook-1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff9e9c1e4e9432bba7a75b7a6b8c2bfd98b33da89bd07bb071fca490c4ad3b74
|
|
| MD5 |
94f2812f85c3c32651fba6419bf76f43
|
|
| BLAKE2b-256 |
0f7c85bdeef87b33b1b115716a30a780b4afc04b2ba3b568dafdf15207ed3b5c
|
Provenance
The following attestation bundles were made for cordhook-1.0.tar.gz:
Publisher:
python-publish.yml on mochathehuman/cordhook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cordhook-1.0.tar.gz -
Subject digest:
ff9e9c1e4e9432bba7a75b7a6b8c2bfd98b33da89bd07bb071fca490c4ad3b74 - Sigstore transparency entry: 213179474
- Sigstore integration time:
-
Permalink:
mochathehuman/cordhook@19034d2230254c33dcfd4f0bc6bbf441471abc34 -
Branch / Tag:
refs/tags/v1.0 - Owner: https://github.com/mochathehuman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@19034d2230254c33dcfd4f0bc6bbf441471abc34 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cordhook-1.0-py3-none-any.whl.
File metadata
- Download URL: cordhook-1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c8b90e5687de3fdc7a14cfe5fb4daa20123ad70cc20e3bb342ccfdfc48c344
|
|
| MD5 |
fdffc2ff396051fa648836f081486624
|
|
| BLAKE2b-256 |
825611c22daab5c01eedf0f0ab011e9d6aae468a40d03b658f5e3e2a2c6555b2
|
Provenance
The following attestation bundles were made for cordhook-1.0-py3-none-any.whl:
Publisher:
python-publish.yml on mochathehuman/cordhook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cordhook-1.0-py3-none-any.whl -
Subject digest:
65c8b90e5687de3fdc7a14cfe5fb4daa20123ad70cc20e3bb342ccfdfc48c344 - Sigstore transparency entry: 213179477
- Sigstore integration time:
-
Permalink:
mochathehuman/cordhook@19034d2230254c33dcfd4f0bc6bbf441471abc34 -
Branch / Tag:
refs/tags/v1.0 - Owner: https://github.com/mochathehuman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@19034d2230254c33dcfd4f0bc6bbf441471abc34 -
Trigger Event:
release
-
Statement type: