Skip to main content

A clean, user-friendly Python package for sending Discord webhook messages and rich embeds.

Project description

webhooklogger-python-rafi

A clean, user-friendly Python package for sending Discord webhook messages and rich embeds.

Installation

pip install webhookloggerx

Quick Start

from webhooklogger import WebhookClient, Embed

client = WebhookClient("https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN")
client.send("Hello from webhooklogger!")

Features

  • ✅ Send plain text messages
  • ✅ Send rich Discord embeds
  • ✅ Send multiple embeds in one request
  • ✅ Customise webhook display name & avatar
  • ✅ Embed builder with fluent (chainable) API
  • ✅ Built-in colour themes (success, error, warning, etc.)
  • ✅ Set embed title, description, author, footer, images, timestamp, fields

WebhookClient

Create a Client

from webhooklogger import WebhookClient

client = WebhookClient("https://discord.com/api/webhooks/...")

Set Webhook Profile (name & avatar)

client.set_profile(
    username="MyBot",
    avatar_url="https://example.com/avatar.png"
)

Send a Plain Text Message

client.send("This is a plain message.")

Send an Embed

from webhooklogger import Embed

embed = Embed().set_title("Hello!").set_description("Embed body here.")
client.send_embed(embed)

Send Multiple Embeds

embed1 = Embed().set_title("First").set_theme("success")
embed2 = Embed().set_title("Second").set_theme("error")
client.send_embeds([embed1, embed2])

Send Text + Embed Together

embed = Embed().set_title("Alert").set_description("Check this out!")
client.send_message(content="Hey team!", embed=embed)

Embed Builder

All methods return self, so you can chain them fluently.

Title & Description

embed = (
    Embed()
    .set_title("My Title")
    .set_description("This is the body of the embed.")
    .set_url("https://example.com")   # makes title clickable
)

Colour

# Hex string
embed.set_color("#FF5733")

# Integer
embed.set_color(16711680)

# Named theme
embed.set_theme("success")

Available themes:

Theme Colour
default Discord Blurple
success Green
warning Yellow
error Red
info Blue
dark Dark Grey
light White
purple Purple
orange Orange
pink Pink

Author

embed.set_author(
    name="Nur Mohammad Rafi",
    url="https://github.com/yourusername",
    icon_url="https://example.com/icon.png"
)

Thumbnail & Image

embed.set_thumbnail("https://example.com/thumb.png")  # top-right corner
embed.set_image("https://example.com/big-image.png")  # large bottom image

Fields

embed.add_field("Status", "Online", inline=True)
embed.add_field("Server", "Production", inline=True)
embed.add_field("Message", "All systems go.", inline=False)
  • inline=True — fields sit side by side (up to 3 per row)
  • inline=False — field takes the full width
  • Max 25 fields per embed

Footer

embed.set_footer("webhooklogger v1.0", icon_url="https://example.com/icon.png")

Timestamp

embed.set_timestamp()        # use current UTC time
from datetime import datetime, timezone
embed.set_timestamp(datetime(2025, 1, 1, tzinfo=timezone.utc))  # custom time

Full Example

from webhooklogger import WebhookClient, Embed

# Create and configure client
client = WebhookClient("https://discord.com/api/webhooks/...")
client.set_profile(username="AlertBot", avatar_url="https://example.com/bot.png")

# Build embed
embed = (
    Embed()
    .set_title("🚨 System Alert")
    .set_description("A critical event has been detected on the server.")
    .set_theme("error")
    .set_author("Monitor System", icon_url="https://example.com/icon.png")
    .set_thumbnail("https://example.com/thumb.png")
    .add_field("Host", "prod-server-01", inline=True)
    .add_field("Status", "❌ Down", inline=True)
    .add_field("Region", "US-East", inline=True)
    .add_field("Details", "Connection timeout after 30s", inline=False)
    .set_image("https://example.com/graph.png")
    .set_footer("webhooklogger • Auto-alert system")
    .set_timestamp()
)

# Send it
client.send_embed(embed)

Error Handling

from webhooklogger import WebhookClient, WebhookError

client = WebhookClient("https://discord.com/api/webhooks/...")

try:
    client.send("Test message")
except WebhookError as e:
    print(f"Failed: HTTP {e.status_code}{e.message}")

API Reference

WebhookClient

Method Description
__init__(url) Create client with webhook URL
set_profile(username, avatar_url) Override display name & avatar
send(content) Send plain text message
send_embed(embed) Send a single Embed
send_embeds(embeds) Send a list of Embeds (max 10)
send_message(content, embed) Send text + embed together

Embed

Method Description
set_title(title) Embed title
set_description(text) Embed body text
set_url(url) Make title a hyperlink
set_color(color) Hex string or int
set_colour(color) Alias for set_color
set_theme(theme) Named colour theme
set_author(name, url, icon_url) Author block
set_thumbnail(url) Small top-right image
set_image(url) Large bottom image
set_footer(text, icon_url) Footer text & icon
set_timestamp(dt) Timestamp (default: now)
add_field(name, value, inline) Add a field
clear_fields() Remove all fields
build() Return raw dict for API

License

MIT © Nur Mohammad Rafi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webhookloggerx-2.0.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webhookloggerx-2.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file webhookloggerx-2.0.1.tar.gz.

File metadata

  • Download URL: webhookloggerx-2.0.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for webhookloggerx-2.0.1.tar.gz
Algorithm Hash digest
SHA256 66f806f75fd80f61d73bf1a27b99a4d4b17aa35d7bb9540eab0bc3791336938b
MD5 85fb7c1adf58c11e5262d3fa390809b8
BLAKE2b-256 fa437f7ff739f909ce8adbc66dc9884d50e5b0ead2c8080ea44b578b08ada544

See more details on using hashes here.

File details

Details for the file webhookloggerx-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: webhookloggerx-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for webhookloggerx-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebfdfc05a75666085bb18f834ca8d9c2c6a57b43f68b4983a3ba7fa45d167306
MD5 9d771222c22f98e55465b4ea8c6463d7
BLAKE2b-256 a3794e74b2c0be35b86e11e6569b5145cf03fbd8aa71a8e912ad1252447737b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page