-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (27 loc) · 888 Bytes
/
script.js
File metadata and controls
33 lines (27 loc) · 888 Bytes
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
const form = document.getElementById("form");
const webhook = document.getElementById("webhook");
const btn = document.getElementById("btn");
async function deleteWebhook() {
event.preventDefault();
if(!webhook.value.startsWith("https://discord.com/api/webhooks/")) {
alert("Please enter a valid Discord webhook URL!");
form.reset();
return;
}
btn.setAttribute("disabled", true);
btn.innerHTML = "Deleting...";
fetch(webhook.value, {
method: "DELETE"
}).catch(() => { alert("An error occurred!"); }).then(res => {
form.reset();
btn.removeAttribute("disabled");
btn.innerHTML = "Delete";
if(res) {
if(res.status === 204) {
alert("Webhook has been deleted!");
} else {
alert("Webhook does not exist!");
}
}
})
}