diff --git a/src/plugins/WebhookManager/index.tsx b/src/plugins/WebhookManager/index.tsx index 341eeddc5..23e678594 100644 --- a/src/plugins/WebhookManager/index.tsx +++ b/src/plugins/WebhookManager/index.tsx @@ -12,6 +12,7 @@ import { RestAPI } from "@webpack/common"; const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative; const WMLogger = new Logger("WebhookManager"); + export default definePlugin({ name: "WebhookManager", description: "Manage your webhooks easily; delete, send messages, get detailed info and more.", @@ -163,12 +164,10 @@ export default definePlugin({ avatar_url: webhookProfilePic, tts: findOption(option, "tts"), }); - } sendBotMessage(ctx.channel.id, { - content: "Message sent successfully." + content: "Your message to the webhook has been executed." }); - } } ] diff --git a/src/plugins/WebhookManager/native.ts b/src/plugins/WebhookManager/native.ts index ae2f108dd..12dcdc890 100644 --- a/src/plugins/WebhookManager/native.ts +++ b/src/plugins/WebhookManager/native.ts @@ -4,19 +4,16 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -/* -todo: also add web support (should be as easy as if navigator is on web or smthn like that, might even have a variable for that somewhere) -(thank you official vendicated vending machine 2024 real) -const iframe = document.createElement("iframe") -iframe.sandbox = "allow-scripts" -iframe.srcdoc = `` -document.body.append(iframe); -setTimeout(() => iframe.remove(), 1000); -*/ import https from "https"; - export function executeWebhook(_, url: string, body: object) { + const { hostname, pathname } = new URL(url); + + if (!["discord.com", "ptb.discord.com", "canary.discord.com"].includes(hostname) || !pathname.startsWith("/api/webhooks/")) { + + throw new Error("This URL is not a valid webhook."); + } + const req = https.request(url, { method: "POST",