-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a Sticker with an apng file does not work - DiscordAPIError[50046] Invalid Asset
#8557
Comments
Could you mess around with
Especially considering that you mentioned it works fine with URLs (in which case we take the response |
With using import {fileTypeFromFile, fileTypeFromBuffer} from 'file-type';
import {readChunk} from 'read-chunk';
import fs from 'fs';
console.log(await fileTypeFromFile('testimage.png'));
const buffer = await readChunk('testimage.png', { length: 4100 });
console.log(await fileTypeFromBuffer(buffer));
const buffer2 = fs.readFileSync('testimage.png');
console.log(await fileTypeFromBuffer(buffer2)); All three returned { ext: 'apng', mime: 'image/apng' }
{ ext: 'apng', mime: 'image/apng' }
{ ext: 'apng', mime: 'image/apng' } Could the issue be due to it not being |
It... sure sounds like it, which would make this an API bug(?), probably.
Could you now fetch the files you were testing with and check what |
Wasn't too sure what you meant by fetching the files, but testing console.log(await DataResolver.resolveFile('https://i.imgur.com/vZbdGUW.png')); |
That works too. Thanks! I'll try to flag this as an API bug and if that doesn't work we'll need to hack this up internally, but I hope they take it. |
I've managed to fix my issue on my side by changing RequestManager locally from const contentType = file.contentType ?? (await fileTypeFromBuffer(file.data))?.mime; to const fileMime = (await fileTypeFromBuffer(file.data))?.mime
const contentType = file.contentType ?? fileMime === 'image/apng' ? 'image/png' : fileMime; Which is a bit jank, in my personal opinion, haha, but it temporarily gets the job done for anyone else who may be having issues with uploading file-based apng stickers. I don't particularly want to make an actual PR as their may be better alternatives, but considering the It might be in merit to consider either a different dependency, or allowing/not throwing an error on content-type |
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 |
As the official list does not include |
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:
Steps to reproduce with below code sample:
guild.stickers.create()
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
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
The text was updated successfully, but these errors were encountered: