Created
July 31, 2022 19:10
-
-
Save bug-assassin/31d2bac321785f659ba2aa9c38e2a7fc to your computer and use it in GitHub Desktop.
Example discord webhook notification in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
webhook = "WEBHOOK_URL" | |
def sendNotification(title, url): | |
data = { | |
"content" : f"{title}", | |
"embeds" : [ | |
{"title" : f"{title}", | |
"url" : f"{url}"} | |
] | |
} | |
result = requests.post(webhook, json = data) | |
try: | |
result.raise_for_status() | |
except requests.exceptions.HTTPError as err: | |
print(err) | |
else: | |
print("Payload delivered successfully, code {}.".format(result.status_code)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment