question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating a Sticker with an apng file does not work - `DiscordAPIError[50046] Invalid Asset`

See original GitHub issue

Which package is this bug report for?

discord.js

Issue description

After updating from v13 to v14, I’ve noticed that one of my previous commands no longer works. Uploading an animated png file now throws this such error:

DiscordAPIError[50046]: Invalid Asset
    at SequentialHandler.runRequest (/home/sethdev/WebstormProjects/EmojiUtilities/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:293:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.queueRequest (/home/sethdev/WebstormProjects/EmojiUtilities/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14)
    at async REST.request (/home/sethdev/WebstormProjects/EmojiUtilities/node_modules/@discordjs/rest/dist/lib/REST.cjs:52:22)
    at async GuildStickerManager.create (/home/sethdev/WebstormProjects/EmojiUtilities/node_modules/discord.js/src/managers/GuildStickerManager.js:67:21)
    at async /home/sethdev/WebstormProjects/EmojiUtilities/src/commands/stickerfy.js:108:7 {
  rawError: { message: 'Invalid Asset', code: 50046 },
  code: 50046,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/guilds/779897232295329793/stickers',
  requestBody: {
    files: [ [Object] ],
    json: { name: 'test', tags: 'banana', description: '' }
  }
}

Steps to reproduce with below code sample:

  1. Create an animated png file
  2. Input it into guild.stickers.create()
  3. Watch it fail

Interestingly enough, it works if the supplied file is an non-animated png or if the file is a URL (A URL apng and png both create a sticker perfectly fine). I’ve checked the magic bytes of several non-animated and animated png files and they are both recognized as pngs; animated png vs non-animated png

My current suspicions of the previous fixes from #8285 and #8290 didnt actually implement a fix for apngs and dont properly assign the png content-type to apngs, maybe?

For replication testing purposes, here is an animated png: https://i.imgur.com/vZbdGUW.png Feel free to try uploading it as a sticker via Discord manually, via the guild.stickers.create() function as a URL, and then again via as a file. The first two should succeed, whilst the last fails.

Code sample

guild.stickers.create({ file: './testimage.png', name: 'test', tags: 'banana' })
.then(console.log)
.catch(console.error)

Package version

14.3.0

Node.js version

18.7.0

Operating system

Arch Linux

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

User, Channel, Message, Reaction

Which gateway intents are you subscribing to?

Guilds, GuildEmojisAndStickers, GuildMessages, GuildMessageReactions, MessageContent

I have tested this issue on a development release

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
didinelecommented, Aug 28, 2022

It might be in merit to consider either a different dependency

No, using a different dependency that yields an (arguably) less correct MIME type is backwards.

or allowing/not throwing an error on content-type image/apng

This isn’t an error we’re throwing, its just what Discord is throwing.

We’ll end up having some logic take care of those special cases if Discord doesn’t accept my issue as a bug, but I haven’t opened that yet as it’s the weekend and I wanted to relax, I’ll be doing it tomorrow. Ideally they do allow us to pass image/apng, in which case no code changes on our end will be needed.

0reactions
advaith1commented, Sep 1, 2022

As the official list does not include image/apng, the actual issue here appears to be file-type returning a non-standard type string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anyone have any idea why I'm getting invalid asset error?
Discord stickers only allow “real” pngs, downloading an image and changing the format by changing the text doesn't work.
Read more >
discord sticker invalid asset | The AI Search Engine You Control
Creating a Sticker with an apng file does not work ​​ Feel free to try uploading it as a sticker via Discord manually,...
Read more >
How To Fix Invalid Asset Error On Discord - Whoihavetobe
In this guide, you will learn how to fix the invalid asset error when you are trying to upload a sticker(s) file to...
Read more >
Problems with animated sticker packs - Apple Developer
I'm having trouble succuessfully making animated stickers in Sticker Pack Applications. When I run my app in the simulator or on a real...
Read more >
How Upload Discord STICKERS! (Full guide!) - YouTube
I show how to make animated Discord Stickers, and also cover Discord ... (exact) Image formats: APNG, Lottie, or PNG File Size Limit:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found