-
Notifications
You must be signed in to change notification settings - Fork 1
/
discord_webhook.py
38 lines (34 loc) · 1.19 KB
/
discord_webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import json
webhook_id = 123456789 # place webhook id
webhook_token = "abcdefghi" # place webhook token
webhook_link = f"https://discordapp.com/api/webhooks/{webhook_id}/{webhook_token}"
def sendToDiscord(title, description, item_link, image_link):
headers = {
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36'
}
data = {
# "username": "Sender Name",
"avatar_url": "",
"embeds": [
{
"title": title,
"description": description,
"url": item_link,
"image": {
"url": image_link,
"height": 400,
"width": 400
}
}
]
}
try:
requests.post(webhook_link, headers=headers, data=json.dumps(data))
except:
print("Failed to make request to discord api")
return
print("Sent to discord ...")
if __name__ == "__main__":
sendToDiscord("Some Title", "This is my message", "https://github.com/TufayelLUS/discord-webhook-python", None)