execute discord webhooks
Project description
python-discord-webhook
execute discord webhooks
Install
install via pip: pip install discord-webhook
Examples
basic webhook
from discord_webhook import DiscordWebhook
webhook = DiscordWebhook(url='your webhook url', content='Webhook Message')
response = webhook.execute()
multiple webhook urls
from discord_webhook import DiscordWebhook
webhook_urls = ['webhook url 1', 'webhook url 2']
webhook = DiscordWebhook(url=webhook_urls, content='Webhook Message')
response = webhook.execute()
webhook with embedded content
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url')
# create embed object for webhook
embed = DiscordEmbed(title='Your Title', description='Lorem ipsum dolor sit', color=242424)
# add embed object to webhook
webhook.add_embed(embed)
response = webhook.execute()
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url')
# create embed object for webhook
embed = DiscordEmbed(title='Your Title', description='Lorem ipsum dolor sit', color=242424)
# set author
embed.set_author(name='Author Name', url='author url', icon_url='author icon url')
# set image
embed.set_image(url='your image url')
# set thumbnail
embed.set_thumbnail(url='your thumbnail url')
# set footer
embed.set_footer(text='Embed Footer Text')
# set timestamp (default is now)
embed.set_timestamp()
# add fields to embed
embed.add_embed_field(name='Field 1', value='Lorem ipsum')
embed.add_embed_field(name='Field 2', value='dolor sit')
# add embed object to webhook
webhook.add_embed(embed)
response = webhook.execute()
This is another example with embedded content
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url', username="New Webhook Username")
embed = DiscordEmbed(title='Embed Title', description='Your Embed Description', color=242424)
embed.set_author(name='Author Name', url='https://github.com/lovvskillz', icon_url='https://avatars0.githubusercontent.com/u/14542790')
embed.set_footer(text='Embed Footer Text')
embed.set_timestamp()
embed.add_embed_field(name='Field 1', value='Lorem ipsum')
embed.add_embed_field(name='Field 2', value='dolor sit')
embed.add_embed_field(name='Field 3', value='amet consetetur')
embed.add_embed_field(name='Field 4', value='sadipscing elitr')
webhook.add_embed(embed)
response = webhook.execute()
send files
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url', username="Webhook with files")
# send two images
with open("path/to/first/image.jpg", "rb") as f:
webhook.add_file(file=f.read(), filename='example.jpg')
with open("path/to/second/image.jpg", "rb") as f:
webhook.add_file(file=f.read(), filename='example2.jpg')
response = webhook.execute()
You can use uploaded attachments in embeds:
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url')
with open("path/to/image.jpg", "rb") as f:
webhook.add_file(file=f.read(), filename='example.jpg')
embed = DiscordEmbed(title='Embed Title', description='Your Embed Description', color=242424)
embed.set_thumbnail(url='attachment://example.jpg')
webhook.add_embed(embed)
response = webhook.execute()
use proxies
from discord_webhook import DiscordWebhook
proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
webhook = DiscordWebhook(url='your webhook url', content='Webhook Message', proxies=proxies)
response = webhook.execute()
or
from discord_webhook import DiscordWebhook
proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
webhook = DiscordWebhook(url='your webhook url', content='Webhook Message')
webhook.set_proxies(proxies)
response = webhook.execute()
use cli
usage: discord_webhook [-h] -u URL [URL ...] -c CONTENT [--username USERNAME]
[--avatar_url AVATAR_URL]
Trigger discord webhook(s).
optional arguments:
-h, --help show this help message and exit
-u URL [URL ...], --url URL [URL ...]
Webhook(s) url(s)
-c CONTENT, --content CONTENT
Message content
--username USERNAME override the default username of the webhook
--avatar_url AVATAR_URL
override the default avatar of the webhook
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
discord-webhook-0.8.0.tar.gz
(6.9 kB
view details)
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 discord-webhook-0.8.0.tar.gz.
File metadata
- Download URL: discord-webhook-0.8.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af98d45ad88b0627eda7e383ffc4b5f356c1f342d2a4f8af638a4248f0b92031
|
|
| MD5 |
9df743839ecb530c04729cb4f21a20de
|
|
| BLAKE2b-256 |
351207128f81e2b0515d3b2ff1687ff148e8a6eaabf2946fa64ba844b9c3de94
|
File details
Details for the file discord_webhook-0.8.0-py3-none-any.whl.
File metadata
- Download URL: discord_webhook-0.8.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f14b066fe1dad8c0a289e3a93774b9c0c73bfce318cf908e85ab55484d59a6b4
|
|
| MD5 |
d72f0fe2c6104879252bbd3d0fed9922
|
|
| BLAKE2b-256 |
daf38914bde8c18e80e57450e74fa041eececcf85134de0c3b7d091262451c90
|