diff --git a/src/index.tsx b/src/index.tsx index 9a8bccf..d46a5d0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,56 +1,11 @@ -import { findByName, findByProps } from "@vendetta/metro"; -import { React } from "@vendetta/metro/common"; -import { after, before } from "@vendetta/patcher"; -import { installPlugin } from "@vendetta/plugins"; -import { installTheme } from "@vendetta/themes"; +import { plugin } from "@vendetta"; +import { removePlugin } from "@vendetta/plugins"; import { getAssetIDByName } from "@vendetta/ui/assets"; -import { Forms } from "@vendetta/ui/components"; import { showToast } from "@vendetta/ui/toasts"; -import { APIMessage } from "discord-api-types/v10"; - -const LazyActionSheet = findByProps("openLazy", "hideActionSheet"); - -const { FormRow } = Forms; -const Icon = findByName("Icon"); - -const HTTP_REGEX = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g; - -let unpatch; export default { onLoad: () => { - unpatch = before("openLazy", LazyActionSheet, ([sheet, name]) => { - if (name !== "MessageLongPressActionSheet") return; - - sheet.then((instance) => { - const unpatchInstance = after("default", instance, ([{ message }]: [{ message: APIMessage }], res) => { - React.useEffect(() => () => { unpatchInstance() }, []); - - const links = message.content?.match(HTTP_REGEX)?.map((link) => link.endsWith("/") || link.endsWith(".json") ? link : `${link}/`) ?? []; - - let rows = res?.props?.children?.props?.children?.props?.children[1] as Array; - - for (const link of links.reverse()) { - const installRow = (} - label={`Install ${link}`} - onPress={() => { - // @ts-expect-error - (link.endsWith(".json") ? installTheme : installPlugin)(link).then(() => { - showToast(`Successfully installed ${link}`, getAssetIDByName("Check")); - }).catch((e) => { - showToast(e.message, getAssetIDByName("Small")); - }).finally(() => { if (links.length <= 1) LazyActionSheet.hideActionSheet() }) - }} - />); - - rows.unshift(installRow); - }; - }); - }); - }); - }, - onUnload: () => { - unpatch(); + removePlugin(plugin.id) + showToast("Message import has been superceded by features built into Vendetta and removed from your client.", getAssetIDByName("ic_information_24px")) }, };