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')
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)
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)
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)
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')
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)
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)
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)
webhook.execute()
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.4.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for discord_webhook-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fde38638acb97354de9cd16863abe61b6053c48d01b15a071056b753c441354a |
|
MD5 | 13d24d9a78e145e487a072a1615b041b |
|
BLAKE2b-256 | 62a64fa6acf6422073af3063a3b700cdc460cfa53eb29bb3ea7c876590b1036b |