community.general.discord module – Send Discord messages
Note
This module is part of the community.general collection (version 10.1.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.discord
.
New in community.general 3.1.0
Synopsis
Sends a message to a Discord channel using the Discord webhook API.
Parameters
Parameter |
Comments |
---|---|
Overrides the default avatar of the webhook. |
|
Send messages as Embeds to the Discord channel. Embeds can have a colored border, embedded images, text fields and more. Allowed parameters are described in the Discord Docs: https://discord.com/developers/docs/resources/channel#embed-object |
|
Set this to Choices:
|
|
Overrides the default username of the webhook. |
|
The webhook ID. Format from Discord webhook URL: |
|
The webhook token. Format from Discord webhook URL: |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
See Also
See also
- API documentation
Documentation for Discord API
Examples
- name: Send a message to the Discord channel
community.general.discord:
webhook_id: "00000"
webhook_token: "XXXYYY"
content: "This is a message from ansible"
- name: Send a message to the Discord channel with specific username and avatar
community.general.discord:
webhook_id: "00000"
webhook_token: "XXXYYY"
content: "This is a message from ansible"
username: Ansible
avatar_url: "https://docs.ansible.com/ansible/latest/_static/images/logo_invert.png"
- name: Send a embedded message to the Discord channel
community.general.discord:
webhook_id: "00000"
webhook_token: "XXXYYY"
embeds:
- title: "Embedded message"
description: "This is an embedded message"
footer:
text: "Author: Ansible"
image:
url: "https://docs.ansible.com/ansible/latest/_static/images/logo_invert.png"
- name: Send two embedded messages
community.general.discord:
webhook_id: "00000"
webhook_token: "XXXYYY"
embeds:
- title: "First message"
description: "This is my first embedded message"
footer:
text: "Author: Ansible"
image:
url: "https://docs.ansible.com/ansible/latest/_static/images/logo_invert.png"
- title: "Second message"
description: "This is my first second message"
footer:
text: "Author: Ansible"
icon_url: "https://docs.ansible.com/ansible/latest/_static/images/logo_invert.png"
fields:
- name: "Field 1"
value: "Value of my first field"
- name: "Field 2"
value: "Value of my second field"
timestamp: "{{ ansible_date_time.iso8601 }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Response Code returned by Discord API. Returned: always Sample: |