-
-
Save Vyasdev217/97557b55afdfd0ac60720e23b88accec to your computer and use it in GitHub Desktop.
Simple discord webhook with python[Forked] : Added simple GUI
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 tkinter | |
import requests #dependency | |
from tkinter import Scrollbar, Tk,ttk,StringVar | |
def webhook_send(): | |
global webhookurl | |
global username | |
global entry_content | |
url =webhookurl.get() | |
#for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook | |
data = { | |
"content" : entry_content.get(1.0, "end-1c"), | |
"username" : username.get() | |
} | |
#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 | |
root=Tk() | |
root.title('Discord webhook sender') | |
root.resizable(0,0) | |
div1=tkinter.Frame(root) | |
div1.grid(row=0,sticky='w') | |
webhookurl=StringVar() | |
label_webhookurl=ttk.Label(div1,text='Webhook url') | |
label_webhookurl.grid(row=0,column=0) # Label | |
entry_webhookurl=ttk.Entry(div1,textvariable=webhookurl) # Textbox | |
entry_webhookurl.grid(row=0,column=1) | |
username=StringVar() | |
label_username=ttk.Label(div1,text='Username') | |
label_username.grid(row=1,column=0) | |
entry_username=ttk.Entry(div1,textvariable=username) | |
entry_username.grid(row=1,column=1) | |
label_content=ttk.Label(root,text='Message content') | |
label_content.grid(row=1,sticky='w') | |
entry_content=tkinter.Text(root) | |
entry_content.grid(row=1) | |
button_send=ttk.Button(root,text='SEND',command=lambda:webhook_send()) | |
button_send.grid(row=2,sticky='e') | |
root.mainloop() | |
# screenshot: https://imgur.com/2Dfgeut.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment