diff --git a/src/plugins/scriptSnippets/index.tsx b/src/plugins/scriptSnippets/index.tsx index 241f5505f..d544539bf 100644 --- a/src/plugins/scriptSnippets/index.tsx +++ b/src/plugins/scriptSnippets/index.tsx @@ -21,21 +21,23 @@ import "./styles.css"; import { ApplicationCommandInputType, ApplicationCommandType, sendBotMessage } from "@api/Commands"; import { Commands, DataStore } from "@api/index"; import { definePluginSettings } from "@api/Settings"; +import { ErrorCard } from "@components/ErrorCard"; import { Switch } from "@components/Switch"; import { Devs } from "@utils/constants"; import { Logger } from "@utils/Logger"; +import { Margins } from "@utils/margins"; import { useAwaiter } from "@utils/react"; import { wordsToKebab as kebab } from "@utils/text"; import definePlugin, { OptionType } from "@utils/types"; import { - Button, + Button, Forms, showToast, Text, TextArea, TextInput, Toasts, useCallback, - useEffect, + useEffect, useMemo, useState } from "@webpack/common"; @@ -43,6 +45,7 @@ const snippetLogger = new Logger("ScriptSnippets"); const wordsToKebab = (words: string) => kebab(words.split(/[\s\-_]+/).map(s => s.replace(/[^\w]/g, ""))); const SNIPPET_KEY = "ScriptSnippets_snippets"; +const UNDERSTOOD_KEY = "ScriptSnippets_understood"; type Snippets = Snippet[]; interface Snippet { @@ -86,13 +89,26 @@ const settings = definePluginSettings({ type: OptionType.COMPONENT, description: "Add snippets to run on certain triggers", component: () => { - const [loadedSnippets, err, pending] = useAwaiter(() => DataStore.get(SNIPPET_KEY)); + const [result, err, pending] = useAwaiter(() => DataStore.getMany([SNIPPET_KEY, UNDERSTOOD_KEY]) as Promise<[Snippets, boolean]>); + const [loadedSnippets, understood] = useMemo(() => result || [], [result]); + // TODO: find a better way to do this const [realSnippets, setRealSnippets] = useState(loadedSnippets || []); + const [realUnderstood, setRealUnderstood] = useState(understood ?? false); + const [canUnderstand, setCanUnderstand] = useState(false); + + useEffect(() => { + if (!realUnderstood) { + const timeout = setTimeout(() => setCanUnderstand(true), 15_000); + + return () => clearTimeout(timeout); + } + }, [realUnderstood]); useEffect(() => { if (!pending && !err) { setRealSnippets(loadedSnippets || []); + setRealUnderstood(understood ?? false); } }, [pending]); @@ -128,6 +144,27 @@ const settings = definePluginSettings({ if (err) return There was an error loading snippets: {err}; + if (!realUnderstood) return + Warning: do not use if you don't understand what you're doing! + + + This plugin has the capability to completely and irreparably damage your Discord installation, environment and computer; access your Discord account credentials and sensitive data stored on your device; and more. + + + + If you were told to paste code in here by someone, there is a 11/10 chance you are being scammed. Only enter code that you completely trust and understand. + + + + You must wait 15 seconds before you can continue. + + + + ; + return ( <> Snippets you create will be registered as a slash command. Changes require a restart to take effect. diff --git a/src/plugins/scriptSnippets/styles.css b/src/plugins/scriptSnippets/styles.css index 134bee108..ba195b46f 100644 --- a/src/plugins/scriptSnippets/styles.css +++ b/src/plugins/scriptSnippets/styles.css @@ -1,3 +1,9 @@ +.vc-scriptsnippets-chance { + text-decoration: underline; + font-weight: bolder; + font-size: 1.3em !important; +} + .vc-scriptsnippets-settings-script { display: flex; flex-direction: row;