From 341151a71811ddf2a7a36af3dc037135d2b9f7dd Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 16 May 2023 19:38:01 -0700 Subject: [PATCH] feat(InvisibleChat): use discords embed api (#1162) --- src/plugins/invisibleChat/index.tsx | 30 +++++++++-------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/plugins/invisibleChat/index.tsx b/src/plugins/invisibleChat/index.tsx index fb173ee8..6f21628a 100644 --- a/src/plugins/invisibleChat/index.tsx +++ b/src/plugins/invisibleChat/index.tsx @@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { getStegCloak } from "@utils/dependencies"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, Tooltip } from "@webpack/common"; +import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, RestAPI, Tooltip } from "@webpack/common"; import { Message } from "discord-types/general"; import { buildDecModal } from "./components/DecryptionModal"; @@ -123,7 +123,7 @@ const settings = definePluginSettings({ export default definePlugin({ name: "InvisibleChat", - description: "Encrypt your Messages in a non-suspicious way! This plugin makes requests to >>https://embed.sammcheese.net<< to provide embeds to decrypted links!", + description: "Encrypt your Messages in a non-suspicious way!", authors: [Devs.SammCheese], dependencies: ["MessagePopoverAPI"], patches: [ @@ -178,25 +178,13 @@ export default definePlugin({ // Gets the Embed of a Link async getEmbed(url: URL): Promise { - const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), 5000); - - const options: RequestInit = { - signal: controller.signal, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - url, - }), - }; - - // AWS hosted url to discord embed object - const rawRes = await fetch(this.EMBED_API_URL, options); - clearTimeout(timeout); - - return await rawRes.json(); + const { body } = await RestAPI.post({ + url: "/unfurler/embed-urls", + body: { + urls: [url] + } + }); + return await body.embeds[0]; }, async buildEmbed(message: any, revealed: string): Promise {