Every time I set up a Discord bot on a fresh Windows PC or a cheap Linux VPS, node-canvas ends up being the package that breaks the install. You are either missing Python, missing Visual Studio C++ build tools, or missing Cairo system headers.
And once you finally get image cards working, you run into the second problem: animation.
Most Discord card packages (like Canvacord) only output static PNGs. If someone in your server pays for Nitro and has an animated avatar, it just freezes on the first frame. And if you try encoding a GIF yourself on the main thread, two bad things happen:
- GIF is from 1987 and only supports 256 colors per frame, so dark gradients and glows get ugly color stripes.
- Encoding 30 frames blocks the Node.js event loop and makes your bot lag on Discord.
I got tired of dealing with this on my own bots, so I built Animafy and just pushed out v3.
Instead of node-canvas, it runs on @napi-rs/canvas (prebuilt binaries, so npm install just works). And instead of blurry GIFs, v3 outputs Animated WebP. Discord plays .webp files inline in chat automatically just like GIFs, except you get full 16.7 million colors, smooth transparent edges, and smaller file sizes. All the heavy encoding runs in background Worker Threads so your bot stays fast.
Here is what the built-in /rank card looks like in v3:
Installing it
You only need two packages:
npm install animafy @napi-rs/canvas Set up one client file in your bot so all your commands share the same asset cache and worker pool:
// src/services/animafy.js import { createAnimafy } from 'animafy'; export const animafy = createAnimafy({ workerPoolSize: 4 }); Making an animated /rank command
Even if a user only has a normal static PNG avatar, animated: true still animates the XP bar fill, counts up the XP numbers, runs a light sweep across the bar, and adds subtle background sparkles.
// src/commands/rank.js import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js'; import { animafy } from '../services/animafy.js'; export const data = new SlashCommandBuilder() .setName('rank') .setDescription('Check your server rank'); export async function execute(interaction) { await interaction.deferReply(); // forceStatic: false lets Discord return an animated avatar if they have Nitro, or a PNG if they don't const avatarUrl = interaction.user.displayAvatarURL({ size: 256, forceStatic: false, extension: 'png' }); const buffer = await animafy.rankCard({ username: interaction.user.username, avatarUrl, level: 42, xp: 8800, maxXp: 10000, rank: 1, status: 'dnd', tag: 'Server Booster', theme: 'neon', animated: true }); // Make sure the file ends in .webp so Discord plays the animation const attachment = new AttachmentBuilder(buffer, { name: 'rank.webp' }); await interaction.editReply({ files: [attachment] }); } Adding a /spotify card
I also added templates for welcomeCard, profileCard, leaderboardCard, levelUpCard, and spotifyCard. Here is the Spotify one with blurred cover art and moving equalizer bars:
const buffer = await animafy.spotifyCard({ title: 'Nightcall', artist: 'Kavinsky', album: 'OutRun', albumArtUrl: albumCoverUrl, elapsedMs: 142000, durationMs: 258000, animated: true }); const attachment = new AttachmentBuilder(buffer, { name: 'spotify.webp' }); await interaction.editReply({ files: [attachment] }); Building custom cards and multi-scene animations
If you don't want pre-made templates and prefer drawing your own layouts, animafy.canvas() and animafy.timeline() let you build custom scenes with frosted glass (drawGlassRect), easing curves (.animate()), particles, transitions like slideLeft or zoomIn, and even Lottie .json animations via .drawLottie().
const webpBuffer = await animafy.timeline() .setSize(800, 250) .setFPS(24) .addScene(c => { c.setBackground('#09090F') .drawGlassRect(20, 20, 760, 210, { blur: 18, radius: 22 }) .drawAvatar(avatarUrl, 120, 125, 62, { borderColor: '#00F0FF', status: 'online' }) .drawText('MATCH FOUND', 212, 104, { fontSize: 13, fontWeight: 'extrabold', letterSpacing: 2, color: '#00F0FF' }) .drawText(`${interaction.user.username} Ready!`, 212, 146, { fontSize: 32, fontWeight: 'extrabold' }); }, 900) .transition('slideLeft', 420, 'easeOutExpo') .addScene(c => { c.setBackground('#090B16') .drawParticles({ count: 36, style: 'confetti' }) .drawText('VICTORY UNLOCKED', 400, 130, { fontSize: 38, fontWeight: 'black', align: 'center', gradient: { stops: [{ offset: 0, color: '#FDE047' }, { offset: 1, color: '#FF2E63' }] } }); }, 900) .exportWebP(); Links
It's completely free and MIT licensed. I've been working on it for a few months and finally got the visual quality where I wanted it with v3.
- GitHub: github.com/demondevx/animafy
- NPM: npmjs.com/package/animafy
Let me know what you think, or if there are any other card templates (like matchup/1v1 cards or economy cards) you'd want me to add next!


