Creating a Sticker with an apng file does not work - `DiscordAPIError[50046] Invalid Asset`
See original GitHub issueWhich 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:
- Create an animated png file
- Input it into
guild.stickers.create()
- 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:
- Created a year ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
No, using a different dependency that yields an (arguably) less correct MIME type is backwards.
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.As the official list does not include
image/apng
, the actual issue here appears to befile-type
returning a non-standard type string.