feat(InvisibleChat): use discords embed api (#1162)
This commit is contained in:
parent
f6fd7cf37a
commit
341151a718
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getStegCloak } from "@utils/dependencies";
|
import { getStegCloak } from "@utils/dependencies";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
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 { Message } from "discord-types/general";
|
||||||
|
|
||||||
import { buildDecModal } from "./components/DecryptionModal";
|
import { buildDecModal } from "./components/DecryptionModal";
|
||||||
|
@ -123,7 +123,7 @@ const settings = definePluginSettings({
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "InvisibleChat",
|
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],
|
authors: [Devs.SammCheese],
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
patches: [
|
patches: [
|
||||||
|
@ -178,25 +178,13 @@ export default definePlugin({
|
||||||
|
|
||||||
// Gets the Embed of a Link
|
// Gets the Embed of a Link
|
||||||
async getEmbed(url: URL): Promise<Object | {}> {
|
async getEmbed(url: URL): Promise<Object | {}> {
|
||||||
const controller = new AbortController();
|
const { body } = await RestAPI.post({
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
url: "/unfurler/embed-urls",
|
||||||
|
body: {
|
||||||
const options: RequestInit = {
|
urls: [url]
|
||||||
signal: controller.signal,
|
}
|
||||||
method: "POST",
|
});
|
||||||
headers: {
|
return await body.embeds[0];
|
||||||
"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();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildEmbed(message: any, revealed: string): Promise<void> {
|
async buildEmbed(message: any, revealed: string): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue