From 814253e735fe5cbd33f078ea8141ed5f6dc610ce Mon Sep 17 00:00:00 2001 From: popboxgun Date: Wed, 27 Jan 2021 10:41:21 +0000 Subject: [PATCH] Update discord with embed information (#16136) Update discord with embed information --- source/_integrations/discord.markdown | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/source/_integrations/discord.markdown b/source/_integrations/discord.markdown index 5e11cea70ef..d79e71d9d34 100644 --- a/source/_integrations/discord.markdown +++ b/source/_integrations/discord.markdown @@ -65,6 +65,30 @@ Right click channel name and copy the channel ID (**Copy ID**). This channel or user ID has to be used as the target when calling the notification service. Multiple channel or user IDs can be specified, across multiple servers or direct messages. +### Discord Service Data + +The following attributes can be placed inside the `data` key of the service call for extended functionality: + +| Attribute | Optional | Description | +| ---------------------- | -------- | ----------- | +| `images` | yes | The file(s) to attach to message. +| `embed` | yes | Array of [Discord embeds](https://discordpy.readthedocs.io/en/latest/api.html#embed). *NOTE*: if using `embed`, `message` is still required. + + +To include messages with embedding, use these attributes underneath the `embed` key: + +| Attribute | Optional | Description | +| ---------------------- | -------- | ----------- | +| `title` | yes | Title of the embed. +| `description` | yes | Description of the embed. +| `color` | yes | Color code of the embed. This value is an *int*. +| `url` | yes | URL of the embed. +| `author` | yes | Sets the footer for the embed content. +| `footer` | yes | Sets the footer for the embed content. +| `thumbnail` | yes | Sets the thumbnail for the embed content. +| `fields` | yes | Adds a field to the embed object. `name` and `value` are *required*, `inline` is *true* by default. + + #### Example service call ```yaml @@ -78,6 +102,40 @@ This channel or user ID has to be used as the target when calling the notificati - "/tmp/garage.jpg" ``` +#### Example embed service call +```yaml +- service: notify.discord + data: + message: "" + target: ["1234567890", "0987654321"] + data: + embed: + title: 'title' + description: 'description' + url: 'https://www.home-assistant.io' + color: 199363 + author: + name: 'Author Home Assistant' + url: 'https://www.home-assistant.io' + icon_url: 'https://www.home-assistant.io/images/favicon-192x192-full.png' + footer: + text: 'Footer Text' + icon_url: 'https://www.home-assistant.io' + thumbnail: + url: 'https://www.home-assistant.io/images/favicon-192x192-full.png' + fields: + - name: 'fieldname1' + value: 'valuename1' + inline: false + - name: 'fieldname2' + value: 'valuename2' + - name: 'fieldname3' + value: 'valuename3' + - name: 'fieldname4' + value: 'valuename4' + inline: false +``` + ### Notes You can tag any user inside a channel by using their user ID in the message like so: `<@userid>` replacing `userid` with the ID you copied. To get the user ID right click on the user name to copy the ID like you did for the channel ID up above.