Skip to content

Instantly share code, notes, and snippets.

@AndyIsHereBoi
Forked from Bilka2/webhook.py
Created May 11, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyIsHereBoi/c4cca7294cf9c4c45ca711dd7016a31f to your computer and use it in GitHub Desktop.
Save AndyIsHereBoi/c4cca7294cf9c4c45ca711dd7016a31f to your computer and use it in GitHub Desktop.
Simple discord webhook with python
import requests #dependency
url = "<your url>" #webhook url, from here: https://i.imgur.com/f9XnAew.png
#for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook
data = {
"content" : "message content",
"avatar" : "direct avatar URL",
"username" : "custom username"
}
#leave this out if you dont want an embed
#for all params, see https://discordapp.com/developers/docs/resources/channel#embed-object
data["embeds"] = [
{
"description" : "text in embed",
"title" : "embed title"
}
]
result = requests.post(url, 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))
#result: https://i.imgur.com/DRqXQzA.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment