mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
might fully work now!!
This commit is contained in:
parent
3b20759c60
commit
ec4e97b187
1 changed files with 44 additions and 35 deletions
|
@ -8,61 +8,70 @@ 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, content, username, avatarUrl = "";
|
||||||
let jsonMode = false;
|
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) {
|
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 <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}
|
||||||
}}
|
/>
|
||||||
|
<Forms.FormTitle className={Margins.top20}>Webhook Username</Forms.FormTitle>
|
||||||
|
<TextInput
|
||||||
|
placeholder={"Username"}
|
||||||
|
value={params.username}
|
||||||
|
onChange={onUsername}
|
||||||
|
/>
|
||||||
|
<Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle>
|
||||||
|
<TextInput
|
||||||
|
placeholder={"Image URL"}
|
||||||
|
value={params.avatarUrl}
|
||||||
|
onChange={onAvatar}
|
||||||
/>
|
/>
|
||||||
<Switch
|
<Switch
|
||||||
key="wm-raw"
|
key="wm-raw"
|
||||||
value={jsonMode}
|
value={jsonMode}
|
||||||
onChange={v => {
|
onChange={onSwitch}
|
||||||
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.
|
|
||||||
>Send as Raw JSON</Switch>
|
>Send as Raw JSON</Switch>
|
||||||
<Forms.FormTitle className={Margins.top20}>Webhook Username</Forms.FormTitle>
|
|
||||||
<TextInput
|
|
||||||
placeholder={"byeoon"}
|
|
||||||
onChange={v => {
|
|
||||||
v = username;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Forms.FormTitle className={Margins.top20}>Webhook Avatar URL</Forms.FormTitle>
|
|
||||||
<TextInput
|
|
||||||
placeholder={"https://cdn.discordapp.com/emojis/1221015075922513990.png"}
|
|
||||||
onChange={v => {
|
|
||||||
v = avatarUrl;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Native.executeWebhook(url, {
|
if (jsonMode != true) {
|
||||||
content: message,
|
Native.executeWebhook(params.url, {
|
||||||
username: username,
|
content: params.content,
|
||||||
avatar_url: avatarUrl
|
username: params.username,
|
||||||
});
|
avatar_url: params.avatarUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Native.executeWebhook(params.url, {
|
||||||
|
content: params.content
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
>Send Webhook</Button>
|
>Send Webhook</Button>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
Loading…
Reference in a new issue