discord
Module for the Discord messenger.
This module defines the Discord messenger class, which is used to send notifications using Discord webhooks to specific servers and channels.
Typical usage example:
from herald.decorators import Herald
from herald.messengers import DiscordMessenger
herald = Herald(".env")
discord = DiscordMessenger()
@herald(discord)
def my_function():
pass
Classes
A class used to send Discord notifications. |
- class DiscordMessenger[source]
Bases:
Messenger
A class used to send Discord notifications.
The webhook URL can be obtained from the server settings inside Discord. You can find instructions on how to do this here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
- Parameters:
webhook_url – String containing the URL for the Discord webhook.
- set_secrets(secrets)[source]
Sets the secrets for the DiscordMessenger class.
The only secret required is the webhook URL.
- Parameters:
secrets (Secrets) – Secrets to be used by the messenger.
- Return type:
None
- notify(info)[source]
Constructs and sends a Discord notification.
- Parameters:
info (TaskInfo) – TaskInfo object containing information about the task that was run. Contents should be used to construct the notification.
- Raises:
HTTPError – An error occurred while making the HTTP request.
- Return type:
None