#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)
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)
womp womp i told you to come here because of this snippet here #๐-js-snippets message
sorry, i deleted it in case that was bad advice but it really did work well for me lol
it only required me to make like one authed request, which i had no issue with doing
What about the group chats?
those can't have custom emojis
no I mean the other thing I was told to come here for the
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels()
oh
use .filter
also forget the "json" part
you are working with native javascript objects
the channels have a type
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
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");
?
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
Okay I fixed the issue and I got something working
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels()
something something filtering right then to json how?
so id 3
i highly suggest learning js properly
const group_dms = Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.id ==3);
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
group_dms;
ah lol
Only thing would be turning this into a big json
JSON.stringify
Vencord.Webpack.Common.ChannelStore.getSortedPrivateChannels().filter(channel => channel.type ==3);
const data = JSON.stringify(group_dms);
oh
Just need to download it lol
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?
where do you want the file
Just having the file download where it want it lol
like you call the other function and you can pick where it downloads
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
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?
you do know this will only download the metadata
hm?
just want to make sure
Because discord doesn't give that easily
that seems right to me
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
lol
probably needs to be in an array
like it was for the emojis
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
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?

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


