Skip to content

mochathehuman/cordhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordhook

PyPI Python License Build Last Commit

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.


PyPi Project Page

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.

About

Python Discord webhook package

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages