mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-27 15:34:26 -04:00
More Plugins
This commit is contained in:
parent
5eefc88ec2
commit
0d9457e1bc
39 changed files with 3648 additions and 2 deletions
29
src/equicordplugins/identity/native.ts
Normal file
29
src/equicordplugins/identity/native.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
export async function RequestRandomUser() {
|
||||
const data = await fetch("https://randomuser.me/api").then(e => e.json());
|
||||
|
||||
return JSON.stringify(data.results[0]);
|
||||
}
|
||||
|
||||
export async function ToBase64ImageUrl(_, data) {
|
||||
const { imgUrl } = data;
|
||||
|
||||
try {
|
||||
const fetchImageUrl = await fetch(imgUrl);
|
||||
const responseArrBuffer = await fetchImageUrl.arrayBuffer();
|
||||
|
||||
const toBase64 =
|
||||
`data:${fetchImageUrl.headers.get("Content-Type") || "image/png"};base64,${Buffer.from(responseArrBuffer).toString("base64")}`;
|
||||
|
||||
return JSON.stringify({ data: toBase64 });
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error converting image to Base64:", error);
|
||||
return JSON.stringify({ error: "Failed to convert image to Base64" });
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue