From 3dd65d520e44c6eba80e5104470397002790eb91 Mon Sep 17 00:00:00 2001 From: byron <47872200+byeoon@users.noreply.github.com> Date: Tue, 12 Mar 2024 11:52:55 -0400 Subject: [PATCH] /webhookinfo has the ability to get a pingable version of the creator, webhook deletion now can determine if the URL is valid --- src/userplugins/WebhookManager.tsx | 31 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/userplugins/WebhookManager.tsx b/src/userplugins/WebhookManager.tsx index 6d1a8594e..b7aa0b64a 100644 --- a/src/userplugins/WebhookManager.tsx +++ b/src/userplugins/WebhookManager.tsx @@ -27,20 +27,23 @@ export default definePlugin({ } ], execute: async (option, ctx) => { - - // const res = await REST.delete(findOption(option, "url")); + const res = await RestAPI.delete(findOption(option, "url")); try { - await RestAPI.delete({ - url: "" + findOption(option, "url") - }); - sendBotMessage(ctx.channel.id, { - content: "Webhook deleted successfully." - }); + if (res.ok == true) { + sendBotMessage(ctx.channel.id, { + content: "Webhook deleted successfully." + }); + } + else { + console.log("WebhookManager encountered an error deleting a webhook. " + res.status); + sendBotMessage(ctx.channel.id, { + content: "There was an error deleting the webhook. Check the console for more info." + }); + } } - catch - { + catch (error) { sendBotMessage(ctx.channel.id, { - content: "Webhook NOT deleted successfully." + content: "There was an error deleting the webhook. Did you input a valid webhook URL?" }); } } @@ -58,8 +61,8 @@ export default definePlugin({ } ], execute: async (option, ctx) => { - var webhookthing = findOption(option, "url"); - await fetch("" + webhookthing).then(response => response.json()) + var webhookUrl = findOption(option, "url"); + await fetch("" + webhookUrl).then(response => response.json()) .then(response => { sendBotMessage(ctx.channel.id, { content: "# Webhook Information: \n" + @@ -73,7 +76,7 @@ export default definePlugin({ "# Webhook Creator Information: \n " + "Creator UserID: " + response.user.id + "\n " + - "Creator Username: " + response.user.name + "\n " + + "Creator Username: " + response.username + " | ( <@" + res.user.id + "> )" + "\n " + "Creator Profile: [Click Me](https://img.discord.dog/" + response.user.id + ") \n" }); });