mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
YAY this should work!!
This commit is contained in:
parent
e88e3b3e13
commit
2cd661f7b6
1 changed files with 24 additions and 22 deletions
|
@ -8,31 +8,35 @@ 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 } from "@webpack/common";
|
import { Button, Forms, React, Switch, TextInput, useState } 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={"https://discord.com/api/webhooks/1235349630980722698/QQv06cMyTurEIU8nQsZRQMKxdmnnN6FA8Eaa9zbDqGwqeeACx9UAS6CcnVt7B3v8r8t2"}
|
placeholder={"Webhook URL"}
|
||||||
onChange={v => {
|
value={params.url}
|
||||||
v = url;
|
onChange={onURL}
|
||||||
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={"Hello World!"}
|
placeholder={"Content"}
|
||||||
onChange={v => {
|
value={params.content}
|
||||||
v = message;
|
onChange={onContent}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Switch
|
<Switch
|
||||||
key="wm-raw"
|
key="wm-raw"
|
||||||
|
@ -44,24 +48,22 @@ 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={"byeoon"}
|
placeholder={"Username"}
|
||||||
onChange={v => {
|
value={params.username}
|
||||||
v = username;
|
onChange={onUsername}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={"https://cdn.discordapp.com/emojis/1221015075922513990.png"}
|
placeholder={"Image URL"}
|
||||||
onChange={v => {
|
value={params.avatarUrl}
|
||||||
v = avatarUrl;
|
onChange={onAvatar}
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Native.executeWebhook(url, {
|
Native.executeWebhook(params.url, {
|
||||||
content: message,
|
content: params.content,
|
||||||
username: username,
|
username: params.username,
|
||||||
avatar_url: avatarUrl
|
avatar_url: params.avatarUrl
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>Send Webhook</Button>
|
>Send Webhook</Button>
|
||||||
|
|
Loading…
Reference in a new issue