#Question about Getting a Server's entire emojis to a zip and every dm I am in to json:

1 messages ยท Page 1 of 1 (latest)

fallow elk
#

How would I turn:

Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels() into a json?

and would i be able to dump a server's emojis in a folder?

fallow elk
#

rooThink i am trying to do it via vencord

#

For safety reasons

mental dune
#

are you serious

#

do not

fallow elk
# mental dune are you serious

rooThink I was told to come here because of the suggestion Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels()

(but it wasn't a json)

#

Just wanted group chats from that

#

downloading emojis was another hope

#
Thread checking ie finding threads in a specific threadchannel ie ones I created/own

Emoji downloads as in complete server or any emoji I select
Separating group chat and dms

(these are the things are wanted but these , but seperating group chats and dms is unlikely)

robust jolt
jolly dragon
#

it only required me to make like one authed request, which i had no issue with doing

robust jolt
#

those can't have custom emojis

fallow elk
robust jolt
#

oh

fallow elk
#

and only getting the group dms

#

but in json

robust jolt
#

use .filter

#

also forget the "json" part

#

you are working with native javascript objects

robust jolt
fallow elk
#

I have zero javascript coding knowledge

#

I really only have enough to go

#

The snippet is safe

#

or enough to find assets and whatnot

#
async function zipServerEmojis(id) {
    await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
    const emojis = Vencord.Webpack.Common.EmojiStore.getGuilds()[id]?.emojis;
    if (!emojis) {
        return console.log("Server not found!");
    }

    const fetchEmojis = async e => {
        const filename = e.id + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + filename + "?size=512&quality=lossless" ).then(res => res.blob());
        return { file: new Uint8Array(await emoji.arrayBuffer()), filename };
    };
    const emojiPromises = emojis.map(e => fetchEmojis(e));

    Promise.all(emojiPromises)
        .then(results => {
            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}
zipServerEmojis("SERVER ID HERE");

(Only problem with this link is that the filename is the emoji id, i like having the extenstion to obut it may be more useful with something like id:name)

#
  • id_name
robust jolt
#

change this line

fallow elk
# robust jolt change this line
async function zipServerEmojis(id) {
    await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
    const emojis = Vencord.Webpack.Common.EmojiStore.getGuilds()[id]?.emojis;
    if (!emojis) {
        return console.log("Server not found!");
    }

    const fetchEmojis = async e => {
        const filename = e.id + "_" + e.name + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + filename + "?size=512&quality=lossless" ).then(res => res.blob());
        return { file: new Uint8Array(await emoji.arrayBuffer()), filename };
    };
    const emojiPromises = emojis.map(e => fetchEmojis(e));

    Promise.all(emojiPromises)
        .then(results => {
            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}
zipServerEmojis("SERVER ID HERE");

?

robust jolt
#

๐ŸŽ‰

#

try it

fallow elk
#

should have probaly looked at it

#

a bit tired rn(I did modify a discordpackage viewing library so)

#

without knowing typescript

#

yeah no luck

#

Oh I see

#

the og name was used to download it from the server

#

so I need to keep it that way for everything until the return

#
async function zipServerEmojis(id) {
    await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
    const emojis = Vencord.Webpack.Common.EmojiStore.getGuilds()[id]?.emojis;
    if (!emojis) {
        return console.log("Server not found!");
    }

    const fetchEmojis = async e => {
        const filename = e.id + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + filename + "?size=512&quality=lossless" ).then(res => res.blob());
        filename = e.id + "_" + e.name + (e.animated ? ".gif" : ".png");
        return { file: new Uint8Array(await emoji.arrayBuffer()), filename };
    };
    const emojiPromises = emojis.map(e => fetchEmojis(e));

    Promise.all(emojiPromises)
        .then(results => {
            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}
zipServerEmojis("SERVER ID HERE");
#

Let me try this

#

yeah no...

#
async function zipServerEmojis(id) {
    await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
    const emojis = Vencord.Webpack.Common.EmojiStore.getGuilds()[id]?.emojis;
    if (!emojis) {
        return console.log("Server not found!");
    }

    const fetchEmojis = async e => {
        let filename = e.id + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + filename + "?size=512&quality=lossless" ).then(res => res.blob());
        filename = e.id + "_" + e.name + (e.animated ? ".gif" : ".png");
        return { file: new Uint8Array(await emoji.arrayBuffer()), filename };
    };
    const emojiPromises = emojis.map(e => fetchEmojis(e));

    Promise.all(emojiPromises)
        .then(results => {
            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}
zipServerEmojis("SERVER ID HERE");
#

Okay that works

fallow elk
# robust jolt ๐ŸŽ‰

Okay I fixed the issue and I got something working

Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels()

something something filtering right then to json how?

robust jolt
fallow elk
#

so id 3

robust jolt
#

i highly suggest learning js properly

fallow elk
#

const group_dms = Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.id ==3);

robust jolt
#

yes

#

wait i am blind

#

you want channel.type

#

not .id

fallow elk
#
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
group_dms;
#

ah lol

#

Only thing would be turning this into a big json

robust jolt
#

JSON.stringify

fallow elk
#
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const data = JSON.stringify(group_dms);
#

oh

#

Just need to download it lol

fallow elk
# robust jolt JSON.stringify
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const group_dm_data = JSON.stringify(group_dms);

How do I make this a json file?

robust jolt
#

where do you want the file

fallow elk
#

Just having the file download where it want it lol

#

like you call the other function and you can pick where it downloads

robust jolt
#

you could just adapt the code for downloading the zip

            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();

remove the emojis definition and replace where it is referenced with your JSON string
replace the mime type with application/json
then change the filename (link.download value)

remember browsers might ask for permission to download multiple files

fallow elk
# robust jolt you could just adapt the code for downloading the zip ```js const em...
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const group_dm_data = JSON.stringify(group_dms);
const link = document.createElement("a");
const blob = new Blob(group_dm_data, { type: "application/json" });
link.href = URL.createObjectURL(blob);
link.download = "group_chats.json";
link.click();
link.remove();
#

That?

robust jolt
#

you do know this will only download the metadata

fallow elk
#

hm?

robust jolt
#

This will not download any messages

#

only information about the channels

fallow elk
#

I only want the channel information

#

to know what group dms I am in

robust jolt
#

just want to make sure

fallow elk
#

Because discord doesn't give that easily

robust jolt
#

that seems right to me

fallow elk
#
const group_dms = Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const group_dm_data = JSON.stringify(group_dms);
const link = document.createElement("a");
const blob = new Blob(group_dm_data, { type: "application/json" });
link.href = URL.createObjectURL(blob);
link.download = "group_chats.json";
link.click();
link.remove();
#

Oops

#
Uncaught TypeError: Failed to construct 'Blob': The provided value cannot be converted to a sequence.
    at <anonymous>:4:14
#

Dang

robust jolt
#

like it was for the emojis

fallow elk
#
const group_dms = Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const link = document.createElement("a");
const blob = new Blob(group_dms, { type: "application/json" });
link.href = URL.createObjectURL(blob);
link.download = "group_chats.json";
link.click();
link.remove();
#

wait no

#

ah so I need to seperate teach json value

robust jolt
#

you need to wrap the first argument to the blob constructor in an array

fallow elk
#

emojis were mapped

#
const group_dms = Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const group_dm_data = JSON.stringify(group_dms);
const link = document.createElement("a");
const blob = new Blob([group_dm_data], { type: "application/json" });
link.href = URL.createObjectURL(blob);
link.download = "group_chats.json";
link.click();
link.remove();
#

Neat

#

This should be all of them?

robust jolt
fallow elk
#

Oh that gif came from the disord api server

#

141 group dms

#

wow

fallow elk
#

It would be cool to see a group dm section viewer plugin (pretty much suggested that lol)