From ec4e97b1879f69de8cf86aa5a335c81883b94ba2 Mon Sep 17 00:00:00 2001 From: byron <47872200+byeoon@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:12:59 -0400 Subject: [PATCH] might fully work now!! --- src/plugins/webhookManager.desktop/index.tsx | 79 +++++++++++--------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/src/plugins/webhookManager.desktop/index.tsx b/src/plugins/webhookManager.desktop/index.tsx index 17b7e1bf7..36084de92 100644 --- a/src/plugins/webhookManager.desktop/index.tsx +++ b/src/plugins/webhookManager.desktop/index.tsx @@ -8,61 +8,70 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { ModalContent, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { Button, Forms, React, Switch, TextInput } from "@webpack/common"; +import { Button, Forms, React, Switch, TextInput, useState } from "@webpack/common"; import definePlugin, { PluginNative } from "@utils/types"; const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative; -let url, message, username, avatarUrl = ""; +let url, content, username, avatarUrl = ""; let jsonMode = false; -// TODO: fix webhooks not sending, fix probable undefined when null issue, add sending as raw again (wanted to make it a checkbox but i cant find checkbox) +// TODO: add sending as raw function WebhookMessageModal(props: ModalProps) { + const [params, setParams] = useState({ content: "", username: "", avatarUrl: "", url: "", jsonMode: false }); + + const onURL = (url: string) => setParams(prev => ({ ...prev, url })); + const onContent = (content: string) => setParams(prev => ({ ...prev, content })); + const onUsername = (username: string) => setParams(prev => ({ ...prev, username })); + const onAvatar = (avatarUrl: string) => setParams(prev => ({ ...prev, avatarUrl })); + const onSwitch = (jsonMode: boolean) => setParams(prev => ({ ...prev, jsonMode })); + + return Webhook URL { - v = url; - console.log(url); // why the FUCK is it undefined. - }} + placeholder={"Webhook URL"} + value={params.url} + onChange={onURL} /> Webhook Message { - v = message; - }} + placeholder={"Content"} + value={params.content} + onChange={onContent} + /> + Webhook Username + + Webhook Avatar URL + { - v = jsonMode; - console.log("hi"); - }} // maybe switch? don't use shitcode where i make an int and set it to 2 and then check if the int is 2 thats too much shitcode. + onChange={onSwitch} >Send as Raw JSON - Webhook Username - { - v = username; - }} - /> - Webhook Avatar URL - { - v = avatarUrl; - }} - />