An easy and simplistic way to execute and modify a Discord webhook all from Python.
Project description
An easy and simplistic way to execute and modify a Discord webhook all from Python.
Install
pip install easy-discord-webhooks
Examples
Sending hello world to a webhook.
import easy_discord_webhooks as DiscordWebhooks # Import easy-discord-webhooks as something easy to refer back to.
webhookUrl = "WEBHOOK_URL_HERE"
webhook = DiscordWebhooks.Webhook(webhookUrl) # Create a new webhook object with your webhook URL.
webhook.send("Hello World") # Send a hello world to the webhook using the objects send function.
Sending a basic embed to a webhook.
import easy_discord_webhooks as DiscordWebhooks # Import easy-discord-webhooks as something easy to refer back to.
webhookUrl = "WEBHOOK_URL_HERE"
webhook = DiscordWebhooks.Webhook(webhookUrl) # Create a new webhook object with your webhook URL.
embed = DiscordWebhooks.Embed( # Create an embed object.
title="Embed Title", # Set the title
description="Embed description...", # Set the description
color="#ff0000" # Set the color (must be a hex value)
)
webhook.send("Hello World", embed=embed) # Send a hello world + the embed to the webhook using the objects send function.
Sending an advanced embed with fields and images to a webhook.
import easy_discord_webhooks as DiscordWebhooks # Import easy-discord-webhooks as something easy to refer back to.
webhookUrl = "WEBHOOK_URL_HERE"
webhook = DiscordWebhooks.Webhook(webhookUrl) # Create a new webhook object with your webhook URL.
embed = DiscordWebhooks.Embed( # Create an embed object.
title="Embed Title", # Set the title
description="Embed description...", # Set the description
color="#ff0000" # Set the color (must be a hex value)
)
# Add fields using add_field function
embed.add_field(name="Field 1", value="Field 1 value.")
embed.add_field(name="Field 2", value="Field 2 value.")
embed.add_field(name="Field 3", value="Field 3 value.")
# Set an image with set_image
embed.set_image(url="https://discord.com/assets/ff41b628a47ef3141164bfedb04fb220.png")
# Set a thumbnail image with set_thumbnail
embed.set_thumbnail(url="https://discord.com/assets/f9bb9c4af2b9c32a2c5ee0014661546d.png")
webhook.send("Hello World", embed=embed) # Send a hello world + the embed to the webhook using the objects send function.
Gather info about a webhook.
import easy_discord_webhooks as DiscordWebhooks # Import easy-discord-webhooks as something easy to refer back to.
webhookUrl = "WEBHOOK_URL_HERE"
webhook = DiscordWebhooks.Webhook(webhookUrl) # Create a new webhook object with your webhook URL.
# get some information from the webhook
username = webhook.name
id = webhook.id
avatar = webhook.avatar
token = webhook.token
# other variables that could come in handy
guildId = webhook.guildId
channelId = webhook.channelId
applicationId = webhook.applicationId
type = webhook.type
# print the information we got from the webhook
print("Webhook name:", username)
print("Webhook id:", id)
print("Webhook token:", token)
print("Webhook avatar:", avatar)
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
File details
Details for the file easy-discord-webhooks-1.0.2.tar.gz
.
File metadata
- Download URL: easy-discord-webhooks-1.0.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2c31de8cad0f25876f11fa16019b8fb07769cbd165022c8aa412a7a46d6ac6b |
|
MD5 | 5fa8c957ea94eafde3794ed3ea69ec92 |
|
BLAKE2b-256 | 3e75970867ffd475d0344173acf5aa1d6a8e8c5743f4cab60c82a5b069bd9761 |