#Sticker zip downloads via zip

1 messages ยท Page 1 of 1 (latest)

potent gate
#

so we have the emojis download script but I don't know how to modify it to work with stickers

sinful orchid
#

but what the fuck are you doing making a thread in js snippets

vestal cedar
sinful orchid
#

@opaque island yo sorry for ping but can u del this thread for obvi reasons

potent gate
#

rooThink hold on though, I am asking how to code such javascript

sinful orchid
#

right

potent gate
#

which is something someone said was okay a while ago

sinful orchid
#

and it is

#

but not here

short whale
#

lmao

sinful orchid
#

i think hes the first person to make a thread in js snippets for the issue of not knowing how to right code

potent gate
sinful orchid
#

and you probably weren't even told that

potent gate
#

I was told to use a js snippets channel in programming at the time

sinful orchid
#

which if i recall correctly does not say "go make a thread and ask for programming support in #๐Ÿ“œ-js-snippets" (but correct me if im wrong)

potent gate
#

I understand why you are frustated but at least you know why I tried to make a thread now, right?

#

there's no reason to be further harsh on me

sinful orchid
#

im not frustrated

#

and not being harsh

#

im just telling you what you should have done instead

potent gate
#

it's how you worded the tone

sinful orchid
#

??

potent gate
# sinful orchid ??

If you look at the actual converstation, no one bothered to help out and I have even been told by a few contributors to use js snippets last time

potent gate
#

if you want people to use the correct channel maybe it's best to follow up in the right channel

#

In short, I understand what channel I can use in the future, I just hope you understand why I put a message in here instead

opaque island
sinful orchid
#

?

opaque island
#

You just seem aggravated for no reason

sinful orchid
#

im not

opaque island
#

sure :)

#

though the only issue I have with this thread is that it has no real relationship with another existing js snippet

sinful orchid
#

the issue i have with it is that its not related to js snippets

opaque island
sinful orchid
#

?

opaque island
sinful orchid
opaque island
# sinful orchid ?

You understand a certain tone in messages can convey something, you seemed harsh but you said you werent but its the complete opposite for your previous messages

#

plugin development is not for js snippets

sinful orchid
#

yeah but i dont think this is a js snippet as theyre im p sure theyre trynna make a plugin

opaque island
#

its fine to make a thread here just associate it with the existing js snippet

sinful orchid
#

wtf is that cursed code ๐Ÿ’€

#

๐Ÿ˜ญ

#

there had to be a better way to do that right

opaque island
#

doesnt matter rlly

#

people have improved it in the thread below

potent gate
#

I barely know javascript

#

I am only able to do so much because of python and general java knowledge

#

I would have zero knowledge on how to code a plugin

glossy warren
#

Sorry i have no real contribution other than JDJG and nyan handled this v well, hope yawl have a nice day

potent gate
#

My biggest problem would be figuring out where the sticker store is

#

cause i have no idea what vencord utils exist

potent gate
#

(and I can barely read javascript so)

potent gate
potent gate
potent gate
#

rooThink is there a util or do I need to grab it from a list of imports?

short whale
#

what are you even doing

potent gate
#

and i have zero knowledge on plugin development

#

and i Don't have a plugin development role

potent gate
short whale
#

there is quite literally no way you can misconstrue my messages to be harsh in the slightest

potent gate
#

you know the emoji download script?

the sticker format isn't the same in terms of utils or file format

#

this is why I need a new version

#

this is not at all related to plugins

short whale
#

again, theres nothing about what i said thats harsh at all, i was simply asking you a question.

short whale
#

this thread, albeit short, is very hard to follow.

potent gate
#

I want my version of emoji download but with stickers instead

#
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");

like the id and sticker name

#

if no sticker id then it would be saved with just sticker name

#

Essentially I want a script that does something similar to this (modifited version of emoji downloader but with stickers of a server instead)

potent gate
#

or something similar

#

but first thing is a sticker download java snippet

potent gate
#

how do I import sticker's list and such?

potent gate
#

and and importing within javascript doesn't work

short whale
#

the evergrowing list continues to grow

potent gate
#

what do you mean?

#
async function ZipStickerEmojis(server_id)
{
    import {findStoreLazy} from "@webpack";
    const StickerStore = findStoreLazy("StickersStore")
}
#

no luck

#

Uncaught SyntaxError: Cannot use import statement outside a module

potent gate
potent gate
#

cause the import doesn't work in javascript snippets

potent gate
#

I think it's a problem that there doesn't seem to be a util to do this

potent gate
#

at least I Cannot find a util if there is one

potent gate
#

May need to make a pull request to add a util to grab stickerstore

#

So I can make thid

#
  • this
short whale
#

this is entertaining

potent gate
#

Entertaining how?

short whale
#

you're just randomly pinging people about whatever this is (apparently something about java), including me, and trying to report to moderators that I'm being rude or whatever.

also, isn't there a stickerstore

potent gate
#

ah stickersstore

#

Ah:

Vencord.Webpack.findStoreLazy("StickersStore")

#

i have no idea how to use that though

potent gate
#
async function ZipStickerEmojis(server_id)
{
   await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
   const stickers = Vencord.Webpack.findStore("StickersStore").
getStickersByGuildId(server_id)
   if (!stickers){
    return console.log("Server not found!");
  }
}

#

I have this so far but there's no asset I could find

#

Like asset is empty

#

\https://cdn.discordapp.com/stickers/1039992459209490513.png

#

I only need that then

#

I need to somehow represent:

pngยถ
Represents a sticker with a png image.

apng
Represents a sticker with an apng image.

lottie
Represents a sticker with a lottie image.

gif
Represents a sticker with a gif image.

#

what is in format_type

#
    png = 1
    apng = 2
    lottie = 3
    gif = 4
#

This will help

#

name and id also exist

potent gate
#
async function ZipStickerEmojis(server_id)
{
   await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
   const stickers = Vencord.Webpack.findStore("StickersStore").
getStickersByGuildId(server_id)
   if (!stickers){
    return console.log("Server not found!");
  }

    const fetchStickers = async s => {
        let filename = s.id + (s.content_type ? ".gif" : ".png");
        const sticker = await fetch("https://cdn.discordapp.com/stickers/" + filename + "?size=512&quality=lossless").then(res => res.blob());
        filename = s.id + "_" + s.name + (s.content_type ? ".gif" : ".png");
         return {file: new Uint8Array(await sticker.arrayBuffer()), filename};
};
const StickersPromises = stickers.map(s => fetchStickers(s));
Promise.all(StickersPromises)
        .then(results => {
            const stickers = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
        const blob = new Blob([stickers], { type: "application/zip" });    
        const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `stickers-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}

await ZipStickerEmojis("1015060230222131221")
#

I have this now but grabbing the sticker urls don't quite work right

#

so for content_type png and apng it should be png
for gif it should be gif
not sure about lottie tho

#

ah lottie is json

#

png -> png
apng -> png
lottie -> json
gif -> gif

#

no real luck with:

async function ZipStickerEmojis(serverId) {
  // Fetch fflate library (consider using a bundler for production)
  await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);

  const stickers = Vencord.Webpack.findStore("StickersStore").getStickersByGuildId(serverId);

  if (!stickers) {
    console.log("Server not found!");
    return; // Early exit if server not found
  }

  const fetchSticker = async (sticker) => {
    let filenameSuffix;
    switch (sticker.format_type) {
      case 1: // png
        filenameSuffix = ".png";
        break;
      case 2: // apng (treated as png)
        filenameSuffix = ".png";
        break;
      case 3: // lottie
        filenameSuffix = ".json";
        break;
      default:
        console.warn(`Unknown format type: ${sticker.format_type}, using .png ${sticker.id}`);
        filenameSuffix = ".png";
    }

    const filename = sticker.id + filenameSuffix;
    const stickerBlob = await fetch("https://cdn.discordapp.com/stickers/" + filename + "?size=512&quality=lossless").then(res => res.blob());

    return { file: new Uint8Array(await stickerBlob.arrayBuffer()), filename };
  };

  const stickerPromises = stickers.map(fetchSticker);

  try {
    const results = await Promise.all(stickerPromises);
    const stickersZip = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
    const blob = new Blob([stickersZip], { type: "application/zip" });

    const link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = `stickers-${serverId}.zip`;
    link.click();
    link.remove();
  } catch (error) {
    console.error(error);
  }
}

await ZipStickerEmojis("1015060230222131221");
#

ooh:
Vencord.Webpack.Common.Constants.Endpoints.STICKER()

potent gate
#

I have an issue with the cross site scriptting error so it makes things more difficult

potent gate
#

could please someone let me know what I util I should be downloading from to not get an error?

rare osprey
#

ahhh always you

short whale
rare osprey
#

not youu

short whale
#

I know, I just find the necroposting a little odd

azure pecan
#

hi

potent gate
#

?

short whale
#

lmao

knotty pewter
# potent gate no real luck with: ```javascript async function ZipStickerEmojis(serverId) { /...

idk why no one else has done it yet ๐Ÿคทโ€โ™‚๏ธ but i made it work

async function ZipStickerEmojis(serverId) {
  // Fetch fflate library (consider using a bundler for production)
  await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);

  const stickers = Vencord.Webpack.findStore("StickersStore").getStickersByGuildId(serverId);

  if (!stickers) {
    console.log("Server not found!");
    return; // Early exit if server not found
  }

  const fetchSticker = async (sticker) => {
    const filename = sticker.id + "."+[, "png", "png", "json", "gif"][sticker.format_type]; // type 2 is APNG
    const stickerBlob = await fetch(window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT+ "/stickers/" + filename + "?quality=lossless").then(res => res.blob());

    return { file: new Uint8Array(await stickerBlob.arrayBuffer()), filename };
  };

  const stickerPromises = stickers.map(fetchSticker);

  try {
    const results = await Promise.all(stickerPromises);
    const stickersZip = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
    const blob = new Blob([stickersZip], { type: "application/zip" });

    const link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = `stickers-${serverId}.zip`;
    link.click();
    link.remove();
  } catch (error) {
    console.error(error);
  }
}

await ZipStickerEmojis("SERVER ID HERE");```
#

@potent gate incase you still need it

potent gate
#

Will try soon

shell fractal
knotty pewter
# shell fractal Hi there! Thank you for making this! <:Prayge:1222894021391810590> Just some ...

oh yeah. i was just trying keep it similar to the emoji download thing. here's a version that downloads with their names

async function ZipStickerEmojis(serverId) {
  // Fetch fflate library (consider using a bundler for production)
  await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);

  const stickers = Vencord.Webpack.findStore("StickersStore").getStickersByGuildId(serverId);

  if (!stickers) {
    console.log("Server not found!");
    return; // Early exit if server not found
  }

  const fetchSticker = async (sticker) => {
    const suffix = "."+[, "png", "png", "json", "gif"][sticker.format_type]; // type 2 is APNG
    const stickerBlob = await fetch(window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT+ "/stickers/" + sticker.id+suffix + "?quality=lossless").then(res => res.blob());

    return { file: new Uint8Array(await stickerBlob.arrayBuffer()), filename: sticker.name+suffix };
  };

  const stickerPromises = stickers.map(fetchSticker);

  try {
    const results = await Promise.all(stickerPromises);
    const stickersZip = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
    const blob = new Blob([stickersZip], { type: "application/zip" });

    const link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = `stickers-${serverId}.zip`;
    link.click();
    link.remove();
  } catch (error) {
    console.error(error);
  }
}

await ZipStickerEmojis("SERVER ID HERE");```
shell fractal
knotty pewter
#

oh

shell fractal
#

unless im using a version different to what you know

knotty pewter
#

i guess i forgot

shell fractal
#

This is for Emojis

    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.name + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + e.id + "?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");```
knotty pewter
#

im probably thinking of that one userplugin that also did the same

shell fractal
#

is it possible to consolidate the two?

knotty pewter
#

like download them into folders of the final zip file?

shell fractal
#

that wasn't what i meant, but that would be nice

#

I mean combine the two snippets for Emojis & Stickers respectively into a single copy+paste

shell fractal
knotty pewter
knotty pewter
#

and maybe i can possibly try soundboard items too (?)

shell fractal
knotty pewter
#

one quirk is that will require fetching the stickers beforehand (entering any vc and opening your soundboard button)

#

unless i figure out how to fetch

knotty pewter
#

yeah i see why no one has done this already now

#
  1. too many call stacks when making subdirectories with this fflate module for some reason (more likely me doing something wrong but i cant figure it out)
  2. final code is too big for me to send
#

probably better off making a plugin for it and keep each expression type as an individual snippet

shell fractal
knotty pewter
#

i'll look into it later

shell fractal
#

I assume the emoji one broke too

#

also, no problem

knotty pewter
#

the script still works for me so im not sure

#

are you using discord desktop, web or vesktop

shell fractal
#

what platform did it work for you ?

#

well, vencord, vesktop & web

knotty pewter
#

i use a fork of vesktop

#

but in theory, it should be the same result

#

unless they changed something on vesktop

shell fractal
craggy grotto