W3cubDocs

/Ansible

community.general.discord – Send Discord messages

Note

This plugin is part of the community.general collection (version 3.8.1).

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 version 3.1.0: of community.general

Synopsis

  • Sends a message to a Discord channel using the Discord webhook API.

Parameters

Parameter Choices/Defaults Comments
avatar_url
string
Overrides the default avatar of the webhook.
content
string
Content of the message to the Discord channel.
At least one of content and embeds must be specified.
embeds
list / elements=dictionary
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
At least one of content and embeds must be specified.
tts
boolean
    Choices:
  • no
  • yes
Set this to true if this is a TTS (Text to Speech) message.
username
string
Overrides the default username of the webhook.
webhook_id
string / required
The webhook ID.
Format from Discord webhook URL: /webhooks/{webhook.id}/{webhook.token}.
webhook_token
string / required
The webhook token.
Format from Discord webhook URL: /webhooks/{webhook.id}/{webhook.token}.

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 Returned Description
http_code
integer
always
Response Code returned by Discord API.

Sample:
204


Authors

  • Christian Wollinger (@cwollinger)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/discord_module.html