feat(stickers): stage Lottie JSON and pass format to sticker registry (v0.8.18)

stageGuildStickerImage detects Lottie via pearcord-lottie, stores
application/lottie+json attachments, and upsertGuildSticker forwards
image bytes for validateSticker. Supports Phase 52 vector stickers.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 23:48:30 -04:00
co-authored by Cursor
parent 0ff4d29ed1
commit d14fc164f5
2 changed files with 16 additions and 7 deletions
+15 -7
View File
@@ -2296,17 +2296,24 @@ class PearcordPlatform extends EventEmitter {
if (!user) throw new Error('register first')
const guildId = this.guild?.guild?.id
if (!guildId) throw new Error('no guild')
const mt = String(mimeType || '').toLowerCase()
const buf = Buffer.isBuffer(data) ? data : Buffer.from(data || [])
let mt = String(mimeType || '').toLowerCase()
const { isAnimatedMime, MAX_STICKER_BYTES } = require('pearcord-stickers')
if (!isAnimatedMime(mt)) {
throw new Error('sticker must be GIF, WebP, PNG, or APNG')
const { LOTTIE_MIME, validateLottieSticker, stickerFormatFromMime } = require('pearcord-lottie')
const fmt = stickerFormatFromMime(mt, buf)
if (fmt === 'lottie') {
const check = validateLottieSticker(buf)
if (!check.valid) throw new Error(check.error || 'invalid lottie')
mt = LOTTIE_MIME
} else if (!isAnimatedMime(mt)) {
throw new Error('sticker must be GIF, WebP, PNG, APNG, or Lottie JSON')
}
if (data?.length > MAX_STICKER_BYTES) {
if (buf.length > MAX_STICKER_BYTES) {
throw new Error('sticker file too large (max 512 KB)')
}
return this.attachments.stage({
data,
filename: filename || 'sticker.gif',
data: buf,
filename: filename || (fmt === 'lottie' ? 'sticker.json' : 'sticker.gif'),
mimeType: mt,
guildId,
channelId: '__sticker__',
@@ -2343,7 +2350,8 @@ class PearcordPlatform extends EventEmitter {
drivePath: att?.drivePath || null,
mimeType: att?.mimeType || null,
filename: att?.filename || null,
packName: packName || null
packName: packName || null,
data: image?.data || null
})
if (att) this.guild.gossipAttachmentMeta(att)
this.guild.gossipStickerUpsert(row)
+1
View File
@@ -13,6 +13,7 @@
"pearcord-message": "file:../pearcord-message",
"pearcord-message-layout": "file:../pearcord-message-layout",
"pearcord-profile-assets": "file:../pearcord-profile-assets",
"pearcord-lottie": "file:../pearcord-lottie",
"pearcord-presence": "file:../pearcord-presence",
"pearcord-invite": "file:../pearcord-invite",
"pearcord-dm": "file:../pearcord-dm",