Skip to content

Latest commit

Β 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

kira-arts πŸ’ž

A TypeScript library for generating Discord-style visual cards β€” profiles, welcome/leave events, level-ups, achievements, leaderboards, compatibility "ship" cards, now-playing music cards, and giveaways β€” rendered natively for speed and zero runtime dependencies on a browser or headless Chromium.

πŸ“š Full documentation, live examples, and a Playground: documentation

npm version npm downloads install size license node types TypeScript tests release GitHub stars commit activity last commit open issues PRs welcome code style: prettier

✨ Features

  • πŸ–ΌοΈ Profile, Welcome/Leave, Level Up, Achievement, Leaderboard, Ship (compatibility), Now Playing, and Giveaway cards
  • 🎡 Now Playing card ships with adapters for moonlink.js, Lavalink-based clients (erela.js, Shoukaku, Kazagumo, Riffy, Magmastream, lavalink-client), discord-player, and distube
  • 🎨 8 built-in themes (discord, midnight, sunset, neon, forest, sakura, monochrome, gold), Nitro/role-color aware borders, and up to 4-color custom gradients
  • 🧾 Output as png, jpeg, or webp, ready to use as a discord.js AttachmentBuilder via toAttachment()
  • ⚑ Built-in, configurable in-memory cache for fetched user data (setCacheOptions, clearCache, getCacheSize)
  • πŸ›‘οΈ Typed error handling with KiraError and KiraErrorCode, instead of opaque runtime failures
  • πŸ“¦ Dual package: ESM and CommonJS builds, both with full type declarations, no extra config needed

πŸ“¦ Installation

npm install kira-arts
yarn add kira-arts
pnpm add kira-arts
bun add kira-arts

Requires Node.js >= 20 and a project with discord.js ^14.27.0 already installed (peer dependency).

πŸš€ Quick usage

import { Client, GatewayIntentBits } from "discord.js";
import { setClient, profileImage, toAttachment } from "kira-arts";

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

client.once("clientReady", () => {
  setClient(client); // πŸ‘ˆ required before generating any card
});

client.on("messageCreate", async (message) => {
  if (message.author.bot || message.content !== "!card") return;

  const buffer = await profileImage(message.author.id, {
    guildId: message.guild?.id,
    useRoleColor: true,
    presenceStatus: message.member?.presence?.status,
    badgesFrame: true,
  });

  await message.reply({ files: [toAttachment(buffer, { name: "profile", extension: "png" })] });
});

client.login(process.env.TOKEN);

Every other card, the music adapters, theming, caching, error handling, and output options are documented with live examples at documentation.

πŸƒ Cards at a glance

Card Function What it's for
Profile profileImage(userId, options) Avatar, badges, nameplate, server tag, rank
Welcome welcomeImage(userId, guildName, options) Member join events
Leave leaveImage(userId, guildName, options) Member leave events
Level Up levelUpImage(userId, level, options) XP progress bar on level-up
Achievement achievementImage(userId, title, options) Unlockable achievements with rarity tiers
Leaderboard leaderboardImage(entries, options) Server ranking table
Ship shipImage(leftUserId, rightUserId, options) Compatibility between two users
Now Playing nowPlayingImage(track, options) Music player card with source detection
Giveaway giveawayImage(prize, options) Prize, host, entry count, winners on end

πŸ› οΈ Utilities

Function What it's for
setClient(client) Registers your discord.js client β€” required before generating any card
toAttachment(buffer, name, format) Wraps a card buffer into a discord.js AttachmentBuilder
encodeCanvas(canvas, options) Encodes a raw canvas to png / jpeg / webp
extensionForFormat(format) Returns the file extension for an OutputFormat
setCacheOptions(options) Configures the internal user-data cache (enable, TTL)
clearCache() Clears the internal user-data cache
getCacheSize() Returns the number of entries currently cached
computeCompatibility(leftUserId, rightUserId) Deterministic compatibility percentage for the Ship card
pickShipMessage(percentage) Flavor text matching a compatibility percentage
getThemePalette(theme) Resolves a KiraThemeName to its full color palette
fromMoonlinkTrack(track) Adapter: moonlink.js track β†’ NowPlayingTrack
fromLavalinkTrack(track) Adapter: Lavalink-based clients β†’ NowPlayingTrack
fromDiscordPlayerTrack(track) Adapter: discord-player track β†’ NowPlayingTrack
fromDistubeTrack(song) Adapter: distube song β†’ NowPlayingTrack
extractRequesterId(track) Pulls the requester's user ID out of any supported track

THEMES (all 8 built-in palettes), KiraError / KiraErrorCode, and lower-level canvas/validation helpers (loadImageSafe, hexToRgb, hexToRgba, drawGradientBorder, drawCoverImage, parseHex, decimalToHex, parseImg, parsePng, isString, isNumber) are also exported for advanced use β€” see the documentation for details.

πŸ“„ License

Kira-Arts is released under the Apache-2.0 License.

Copyright Β© worddevs

πŸ”— Links


Made with πŸ’ž by WordDevs

Built with TypeScript, designed for performance.

About

🎨 TypeScript library for generating Discord-style profile, welcome, and achievement cards

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages