# Discord Webhooks for Python 🔗 🐍
[](https://travis-ci.org/JamesIves/discord-webhooks) [](https://github.com/JamesIves/discord-webhooks/issues)
Simple module for Python which allows for sending of webhooks to a [Discord server](https://discordapp.com/).
## Installation Steps 💽
The `Discord-Webhooks` module can be installed into your project via Pip.
```
$ pip install Discord-Webhooks
```
## Getting Started :airplane:
Import the package into your project and initialize it to get started. You must pass the [webhook URL you obtained from your Discord channel in as the argument](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks).
```python
from discord_webhooks import DiscordWebhooks
# Webhook URL for your Discord channel.
WEBHOOK_URL = 'http://discord.gg/...'
# Initialize the webhook class and attaches data.
webhook = DiscordWebhooks(WEBHOOK_URL)
# Sets some content for a basic message.
webhook.set_content(content='Montezuma!')
# Triggers the payload to be sent to Discord.
webhook.send()
```
If you'd like to send a message attachment you can do so.
```python
from discord_webhooks import DiscordWebhooks
# Webhook URL for your Discord channel.
WEBHOOK_URL = 'http://discord.gg/...'
webhook = DiscordWebhooks(WEBHOOK_URL)
webhook.set_content(content='The best cat ever is...', title='Montezuma!', description='Seriously!', \
url='http://github.com/JamesIves', color=0xF58CBA, timestamp='2018-11-09T04:10:42.039Z')
# Attaches an image
webhook.set_image(url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches a thumbnail
webhook.set_thumbnail(url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches an author
webhook.set_author(name='James Ives', url='https://jamesiv.es', icon_url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches a footer
webhook.set_footer(text='Footer', icon_url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Appends a field
webhook.add_field(name='Field', value='Value!')
webhook.send()
```
## Methods 📡
You can find an explanation of all available methods below.
---
#### `set_content`
The `set_content` method can be used to send basic messages to Discord.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `content` | Content represents a standard message on Discord. | `String` |
| `title` | Displays a title on an message attachment. | `String` |
| `description` | Displays a description on an message attachment. | `String` |
| `url` | Creates a link on the title. | `String` |
| `color` | Displays a colored strip on the left side of an message attachment. This should be a hexademical value, for example `0xF58CBA`. | `Integer` |
| `timestamp` | Displays a timestamp beneath the message attachment. Must be a valid timestamp, consider using Python's `datetime` to achieve localtime. | `String` |
---
#### `set_author`
Using `set_author` you're able to attach an author to an message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `name` | The name of the author. | `String` |
| `url` | Creates a link on the author name. | `String` |
| `icon_url` | Displays an author icon, must resolve to a valid image path. | `String` |
---
#### `set_footer`
Using `set_footer` you're able to attach a footer to an message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `text` | The text that should display in the footer. | `String` |
| `icon_url` | Displays a footer icon, must resolve to a valid image path. | `String` |
---
#### `set_thumbnail`
Using `set_thumbnail` you're able to attach a thumbnail to a message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `url` | Displays a thumbnail image in the message attachment | `String` |
---
##### `set_image`
Using `set_image` you're able to attach an image to a message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `url` | Displays an image in the message attachment | `String` |
---
#### `add_field`
Using `add_field` you're able to attach a field to a message attachment. You can add as many fields as you want.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `name` | The name of the field. | `String` |
| `value` | The value of the field. | `String` |
| `inline` | Determines if the field should display inline or not, this is primarily used for formatting when you have multiple fields. | `Boolean` |
---
#### `send`
When you're done formatting your message attachment you can use the `send` method to dispatch it to Discord.
[](https://travis-ci.org/JamesIves/discord-webhooks) [](https://github.com/JamesIves/discord-webhooks/issues)
Simple module for Python which allows for sending of webhooks to a [Discord server](https://discordapp.com/).
## Installation Steps 💽
The `Discord-Webhooks` module can be installed into your project via Pip.
```
$ pip install Discord-Webhooks
```
## Getting Started :airplane:
Import the package into your project and initialize it to get started. You must pass the [webhook URL you obtained from your Discord channel in as the argument](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks).
```python
from discord_webhooks import DiscordWebhooks
# Webhook URL for your Discord channel.
WEBHOOK_URL = 'http://discord.gg/...'
# Initialize the webhook class and attaches data.
webhook = DiscordWebhooks(WEBHOOK_URL)
# Sets some content for a basic message.
webhook.set_content(content='Montezuma!')
# Triggers the payload to be sent to Discord.
webhook.send()
```
If you'd like to send a message attachment you can do so.
```python
from discord_webhooks import DiscordWebhooks
# Webhook URL for your Discord channel.
WEBHOOK_URL = 'http://discord.gg/...'
webhook = DiscordWebhooks(WEBHOOK_URL)
webhook.set_content(content='The best cat ever is...', title='Montezuma!', description='Seriously!', \
url='http://github.com/JamesIves', color=0xF58CBA, timestamp='2018-11-09T04:10:42.039Z')
# Attaches an image
webhook.set_image(url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches a thumbnail
webhook.set_thumbnail(url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches an author
webhook.set_author(name='James Ives', url='https://jamesiv.es', icon_url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Attaches a footer
webhook.set_footer(text='Footer', icon_url='https://avatars1.githubusercontent.com/u/10888441?s=460&v=4')
# Appends a field
webhook.add_field(name='Field', value='Value!')
webhook.send()
```
## Methods 📡
You can find an explanation of all available methods below.
---
#### `set_content`
The `set_content` method can be used to send basic messages to Discord.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `content` | Content represents a standard message on Discord. | `String` |
| `title` | Displays a title on an message attachment. | `String` |
| `description` | Displays a description on an message attachment. | `String` |
| `url` | Creates a link on the title. | `String` |
| `color` | Displays a colored strip on the left side of an message attachment. This should be a hexademical value, for example `0xF58CBA`. | `Integer` |
| `timestamp` | Displays a timestamp beneath the message attachment. Must be a valid timestamp, consider using Python's `datetime` to achieve localtime. | `String` |
---
#### `set_author`
Using `set_author` you're able to attach an author to an message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `name` | The name of the author. | `String` |
| `url` | Creates a link on the author name. | `String` |
| `icon_url` | Displays an author icon, must resolve to a valid image path. | `String` |
---
#### `set_footer`
Using `set_footer` you're able to attach a footer to an message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `text` | The text that should display in the footer. | `String` |
| `icon_url` | Displays a footer icon, must resolve to a valid image path. | `String` |
---
#### `set_thumbnail`
Using `set_thumbnail` you're able to attach a thumbnail to a message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `url` | Displays a thumbnail image in the message attachment | `String` |
---
##### `set_image`
Using `set_image` you're able to attach an image to a message attachment.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `url` | Displays an image in the message attachment | `String` |
---
#### `add_field`
Using `add_field` you're able to attach a field to a message attachment. You can add as many fields as you want.
| Argument | Description | Type |
| ------------- | ------------- | ------------- |
| `name` | The name of the field. | `String` |
| `value` | The value of the field. | `String` |
| `inline` | Determines if the field should display inline or not, this is primarily used for formatting when you have multiple fields. | `Boolean` |
---
#### `send`
When you're done formatting your message attachment you can use the `send` method to dispatch it to Discord.
Metadata
Release files for Discord-Webhooks 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Discord_Webhooks-1.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Release files / Discord_Webhooks-1.0.4-py2.py3-none-any.whl
| Download URL | Discord_Webhooks-1.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b8db5fbf80edd0324df095419eac62826b2f5b93680684d3e941f6376d9cf567
|
|
BLAKE2b-256 checksum How to use checksums |
331a20ecb0605187e01c82af44f563ae6ade81ef39fb9908fad9e2b6b680aea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15
|