hewlp vinneie vnecord no work

This commit is contained in:
byron 2024-06-21 20:31:05 -04:00
parent 2cd661f7b6
commit 5e52a34205

View file

@ -8,35 +8,31 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption,
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { ModalContent, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { ModalContent, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { Button, Forms, React, Switch, TextInput, useState } from "@webpack/common"; import { Button, Forms, React, Switch, TextInput } from "@webpack/common";
import definePlugin, { PluginNative } from "@utils/types"; import definePlugin, { PluginNative } from "@utils/types";
const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>; const Native = VencordNative.pluginHelpers.WebhookManager as PluginNative<typeof import("./native")>;
let url, message, username, avatarUrl = ""; let url, message, username, avatarUrl = "";
let jsonMode = false; let jsonMode = false;
const [params, setParams] = useState({ content: "", username: "", avatarUrl: "", url: "" });
const onURL = (content: 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 }));
// 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: 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)
function WebhookMessageModal(props: ModalProps) { function WebhookMessageModal(props: ModalProps) {
return <ModalRoot {...props} size={ModalSize.MEDIUM} className={"wm-send-webhook"} > return <ModalRoot {...props} size={ModalSize.MEDIUM} className={"wm-send-webhook"} >
<ModalContent className="wm-send-webhook-content"> <ModalContent className="wm-send-webhook-content">
<Forms.FormTitle className={Margins.top20}>Webhook URL</Forms.FormTitle> <Forms.FormTitle className={Margins.top20}>Webhook URL</Forms.FormTitle>
<TextInput <TextInput
placeholder={"Webhook URL"} placeholder={"https://discord.com/api/webhooks/1235349630980722698/QQv06cMyTurEIU8nQsZRQMKxdmnnN6FA8Eaa9zbDqGwqeeACx9UAS6CcnVt7B3v8r8t2"}
value={params.url} onChange={v => {
onChange={onURL} v = url;
console.log(url); // why the FUCK is it undefined.
}}
/> />
<Forms.FormTitle className={Margins.top20}>Webhook Message</Forms.FormTitle> <Forms.FormTitle className={Margins.top20}>Webhook Message</Forms.FormTitle>
<TextInput <TextInput
placeholder={"Content"} placeholder={"Hello World!"}
value={params.content} onChange={v => {
onChange={onContent} v = message;
}}
/> />
<Switch <Switch
key="wm-raw" key="wm-raw"
@ -48,22 +44,24 @@ function WebhookMessageModal(props: ModalProps) {
>Send as Raw JSON</Switch> >Send as Raw JSON</Switch>
<Forms.FormTitle className={Margins.top20}>Webhook Username</Forms.FormTitle> <Forms.FormTitle className={Margins.top20}>Webhook Username</Forms.FormTitle>
<TextInput <TextInput
placeholder={"Username"} placeholder={"byeoon"}
value={params.username} onChange={v => {
onChange={onUsername} v = username;
}}
/> />
<Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle> <Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle>
<TextInput <TextInput
placeholder={"Image URL"} placeholder={"https://cdn.discordapp.com/emojis/1221015075922513990.png"}
value={params.avatarUrl} onChange={v => {
onChange={onAvatar} v = avatarUrl;
}}
/> />
<Button <Button
onClick={() => { onClick={() => {
Native.executeWebhook(params.url, { Native.executeWebhook(url, {
content: params.content, content: message,
username: params.username, username: username,
avatar_url: params.avatarUrl avatar_url: avatarUrl
}); });
}} }}
>Send Webhook</Button> >Send Webhook</Button>