kira-arts 1.2.5 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A TypeScript library for generating Discord-style visual cards — profiles, welcome/leave events, level-ups, achievements, leaderboards, compatibility "ship" cards, and now-playing music cards — all powered by `@napi-rs/canvas`.
4
4
 
5
+ **📚 Full documentation, live examples, and a Playground: [documentation](https://kira-arts.chocofactory.dev/)**
6
+
7
+ > 🔧 **Heads up:** the documentation is currently hosted at `kira-arts.chocofactory.dev`. This will move to a dedicated, more formal custom domain/branding in an upcoming release — the link above will be kept up to date when that happens.
8
+
5
9
  [![npm version](https://img.shields.io/npm/v/kira-arts.svg)](https://www.npmjs.com/package/kira-arts)
6
10
  [![npm downloads](https://img.shields.io/npm/dm/kira-arts.svg)](https://www.npmjs.com/package/kira-arts)
7
11
  [![install size](https://packagephobia.com/badge?p=kira-arts)](https://packagephobia.com/result?p=kira-arts)
@@ -13,7 +17,7 @@ A TypeScript library for generating Discord-style visual cards — profiles, wel
13
17
  [![release](https://github.com/worddevs/kira-arts/actions/workflows/release.yml/badge.svg)](https://github.com/worddevs/kira-arts/actions/workflows/release.yml)
14
18
  [![GitHub stars](https://img.shields.io/github/stars/worddevs/kira-arts.svg?style=flat)](https://github.com/worddevs/kira-arts/stargazers)
15
19
  [![GitHub forks](https://img.shields.io/github/forks/worddevs/kira-arts.svg?style=flat)](https://github.com/worddevs/kira-arts/network/members)
16
- [![contributors](https://img.shields.io/github/contributors/worddevs/kira-arts.svg)](https://github.com/worddevs/kira-arts/graphs/contributors)
20
+ [![contributors](https://img.shields.io/badge/contributors-2-orange)](https://github.com/worddevs/kira-arts/graphs/contributors)
17
21
  [![last commit](https://img.shields.io/github/last-commit/worddevs/kira-arts.svg)](https://github.com/worddevs/kira-arts/commits/main)
18
22
  [![open issues](https://img.shields.io/github/issues/worddevs/kira-arts.svg)](https://github.com/worddevs/kira-arts/issues)
19
23
  [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)
@@ -21,26 +25,17 @@ A TypeScript library for generating Discord-style visual cards — profiles, wel
21
25
 
22
26
  ## ✨ Features
23
27
 
24
- - 🖼️ **Profile Card** user profile with avatar, badges, nameplate, server tag, and rank.
25
- - 👋 **Welcome / Leave Card** customizable join/leave event cards.
26
- - 📈 **Level Up Card** — level-up card with an XP progress bar.
27
- - 🏆 **Achievement Card** — achievement card with rarity (`common`, `rare`, `epic`, `legendary`).
28
- - 🏅 **Leaderboard Card** — ranking table with up to 15 entries.
29
- - 💘 **Ship Card** — compatibility card between two users.
30
- - 🎵 **Now Playing Card** — music player card with progress bar, source badge (YouTube, Spotify, SoundCloud, Twitch, Deezer, Apple Music, etc.), and live-stream support. Ships with adapters for moonlink.js, Lavalink-based clients, discord-player, and distube.
31
- - 🎨 **Built-in themes**: `discord`, `midnight`, `sunset`, `neon`, `forest`, `sakura`, `monochrome`, `gold`.
32
- - 🗃️ Configurable internal cache for user data.
33
- - 🧾 Output as `png`, `jpeg`, or `webp`, ready to use as a discord.js `AttachmentBuilder`.
28
+ - 🖼️ Profile, Welcome/Leave, Level Up, Achievement, Leaderboard, Ship (compatibility), and Now Playing cards
29
+ - 🎵 Now Playing card ships with adapters for moonlink.js, Lavalink-based clients, discord-player, and distube
30
+ - 🎨 8 built-in themes, Nitro/role-color aware borders, and up to 4-color custom gradients
31
+ - 🧾 Output as `png`, `jpeg`, or `webp`, ready to use as a discord.js `AttachmentBuilder`
34
32
 
35
33
  ## 📦 Installation
36
34
 
37
- ```cmd
35
+ ```bash
38
36
  npm install kira-arts
39
-
40
- pnpm add kira-arts
41
-
42
37
  yarn add kira-arts
43
-
38
+ pnpm add kira-arts
44
39
  bun add kira-arts
45
40
  ```
46
41
 
@@ -48,197 +43,77 @@ bun add kira-arts
48
43
 
49
44
  ## 🚀 Quick usage
50
45
 
51
- Register your discord.js client **once** at startup:
52
-
53
46
  ```ts
54
47
  import { Client, GatewayIntentBits } from "discord.js";
55
- import { setClient } from "kira-arts";
48
+ import { setClient, profileImage, toAttachment } from "kira-arts";
56
49
 
57
50
  const client = new Client({ intents: [GatewayIntentBits.Guilds] });
58
51
 
59
- client.once("ready", () => {
52
+ client.once("clientReady", () => {
60
53
  setClient(client); // 👈 required before generating any card
61
54
  });
62
55
 
63
- client.login(process.env.TOKEN);
64
- ```
65
-
66
- ### Profile card
67
-
68
- ```ts
69
- import { profileImage, toAttachment } from "kira-arts";
70
-
71
- const buffer = await profileImage(userId, {
72
- guildId: interaction.guildId!,
73
- useRoleColor: true,
74
- theme: "discord",
75
- presenceStatus: "online",
76
- });
77
-
78
- const attachment = toAttachment(buffer, "profile", "png");
79
- await interaction.reply({ files: [attachment] });
80
- ```
81
-
82
- ### Welcome / leave
83
-
84
- ```ts
85
- import { welcomeImage, leaveImage } from "kira-arts";
86
-
87
- const buffer = await welcomeImage(userId, guild.name, {
88
- memberCount: guild.memberCount,
89
- theme: "sunset",
90
- });
91
- ```
92
-
93
- ### Level up
94
-
95
- ```ts
96
- import { levelUpImage } from "kira-arts";
97
-
98
- const buffer = await levelUpImage(userId, 12, {
99
- currentXp: 450,
100
- requiredXp: 1000,
101
- theme: "neon",
102
- });
103
- ```
104
-
105
- ### Achievement
106
-
107
- ```ts
108
- import { achievementImage } from "kira-arts";
109
-
110
- const buffer = await achievementImage(userId, "First victory!", {
111
- description: "Win your first ranked match.",
112
- rarity: "epic",
113
- });
114
- ```
115
-
116
- ### Leaderboard
117
-
118
- ```ts
119
- import { leaderboardImage } from "kira-arts";
120
-
121
- const buffer = await leaderboardImage(
122
- [
123
- { userId: "111", currentXp: 900, requiredXp: 1000, level: 20 },
124
- { userId: "222", currentXp: 300, requiredXp: 800, level: 14 },
125
- ],
126
- { title: "Server Top", theme: "gold", maxEntries: 10 },
127
- );
128
- ```
56
+ client.on("interactionCreate", async (interaction) => {
57
+ if (interaction.isChatInputCommand()) return;
129
58
 
130
- ### Ship (compatibility)
59
+ if (interaction.commandName === "card") {
60
+ const buffer = await profileImage(interaction.user.id, {
61
+ guildId: interaction.guild?.id,
62
+ useRoleColor: true,
63
+ presenceStatus: interaction.member?.presence?.status,
64
+ customBadges: extraBadges.length ? extraBadges : undefined,
65
+ badgesFrame: true,
66
+ });
131
67
 
132
- ```ts
133
- import { shipImage } from "kira-arts";
134
-
135
- const buffer = await shipImage(userIdA, userIdB, {
136
- theme: "midnight",
137
- showText: true,
138
- });
139
- ```
140
-
141
- ### Now playing
142
-
143
- ```ts
144
- import { nowPlayingImage } from "kira-arts";
145
-
146
- const buffer = await nowPlayingImage(
147
- {
148
- title: "Blinding Lights",
149
- author: "The Weeknd",
150
- artworkUrl: track.artworkUrl,
151
- duration: 200_040,
152
- sourceName: "spotify",
153
- },
154
- {
155
- position: 45_000,
156
- requesterId: interaction.user.id,
157
- guildId: interaction.guildId!,
158
- theme: "midnight",
159
- },
160
- );
161
- ```
162
-
163
- For a livestream / radio, omit `duration` (or set it to `0`) and set `isStream: true` — the card shows a `LIVE` badge and a full progress bar instead of a position.
164
-
165
- #### Music library adapters
166
-
167
- You don't have to build the `track` object by hand. If you're using a supported player library, convert its track object directly:
168
-
169
- ```ts
170
- import { nowPlayingImage, fromMoonlinkTrack, fromLavalinkTrack, fromDiscordPlayerTrack, fromDistubeTrack, extractRequesterId } from "kira-arts";
171
-
172
- // moonlink.js
173
- const buffer = await nowPlayingImage(fromMoonlinkTrack(player.current), {
174
- requesterId: extractRequesterId(player.current),
68
+ await interaction.reply({ files: [toAttachment(buffer, "profile", "png")] });
69
+ }
175
70
  });
176
71
 
177
- // Lavalink-based clients (erela.js, Shoukaku, Kazagumo, Riffy, Magmastream, lavalink-client)
178
- const buffer = await nowPlayingImage(fromLavalinkTrack(track));
179
-
180
- // discord-player
181
- const buffer = await nowPlayingImage(fromDiscordPlayerTrack(queue.currentTrack));
182
-
183
- // distube
184
- const buffer = await nowPlayingImage(fromDistubeTrack(queue.songs[0]));
185
- ```
186
-
187
- Each adapter is a plain duck-typed converter — kira-arts doesn't depend on any of these libraries, so any object with a matching shape works, including one you build yourself from a raw API response.
188
-
189
- ## 🎨 Available themes
190
-
191
- ```
192
- discord | midnight | sunset | neon | forest | sakura | monochrome | gold
72
+ client.login(process.env.TOKEN);
193
73
  ```
194
74
 
195
- Pass it as `theme` in any card's options, or use `getThemePalette(theme)` to get the raw palette.
196
-
197
- ## 🗃️ Cache
75
+ Every other card, the music adapters, theming, caching, error handling, and output options are documented with live examples at **[documentation](https://kira-arts.chocofactory.dev/)**.
198
76
 
199
- ```ts
200
- import { setCacheOptions, clearCache, getCacheSize } from "kira-arts";
77
+ ## 🃏 Cards at a glance
201
78
 
202
- setCacheOptions({ ttl: 60_000 }); // example, adjust to your actual options
203
- clearCache();
204
- console.log(getCacheSize());
205
- ```
79
+ | Card | Function | What it's for |
80
+ | --------------- | --------------------------------- | ------------------------------------------- |
81
+ | Profile | `profileImage()` | Avatar, badges, nameplate, server tag, rank |
82
+ | Welcome / Leave | `welcomeImage()` / `leaveImage()` | Member join/leave events |
83
+ | Level Up | `levelUpImage()` | XP progress bar on level-up |
84
+ | Achievement | `achievementImage()` | Unlockable achievements with rarity tiers |
85
+ | Leaderboard | `leaderboardImage()` | Server ranking table |
86
+ | Ship | `shipImage()` | Compatibility between two users |
87
+ | Now Playing | `nowPlayingImage()` | Music player card with source detection |
206
88
 
207
- ## ⚠️ Error handling
89
+ ## 🤝 Contributors
208
90
 
209
- Every function throws a `KiraError` with a typed `code` (`KiraErrorCode`):
91
+ Kira-Arts is developed and maintained by the WordDevs community.
210
92
 
211
- ```ts
212
- import { KiraError, KiraErrorCode } from "kira-arts";
93
+ <a href="https://github.com/worddevs/kira-arts/graphs/contributors">
94
+ <img src="https://contrib.rocks/image?repo=worddevs/kira-arts" alt="Contributors" />
95
+ </a>
213
96
 
214
- try {
215
- await profileImage(userId);
216
- } catch (err) {
217
- if (err instanceof KiraError && err.code === KiraErrorCode.Validation) {
218
- // handle validation error
219
- }
220
- }
221
- ```
222
-
223
- Available codes: `Validation`, `Fetch`, `AssetLoad`, `Render`, `Config`.
97
+ ## 📄 License
224
98
 
225
- ## 📤 Output format
99
+ Kira-Arts is released under the **Apache-2.0 License**.
226
100
 
227
- Every image-generating function returns a `Buffer`. Control format/quality with `output`:
101
+ Copyright © [worddevs](https://github.com/worddevs)
228
102
 
229
- ```ts
230
- await profileImage(userId, {
231
- output: { format: "webp", quality: 90 },
232
- });
233
- ```
234
-
235
- Supported formats: `png`, `jpeg`, `webp`.
103
+ ## 🔗 Links
236
104
 
237
- ## 📄 License
105
+ - 📚 **Documentation:** https://kira-arts.chocofactory.dev/
106
+ - 📦 **NPM:** https://www.npmjs.com/package/kira-arts
107
+ - 💻 **Repository:** https://github.com/worddevs/kira-arts
108
+ - 🐛 **Issues:** https://github.com/worddevs/kira-arts/issues
109
+ - 🔀 **Contributing:** https://github.com/worddevs/kira-arts/blob/main/CONTRIBUTING.md
238
110
 
239
- Apache-2.0 © [worddevs](https://github.com/worddevs)
111
+ ---
240
112
 
241
- ## 🔗 Links
113
+ <p align="center">
114
+ Made with 💞 by <a href="https://github.com/worddevs">WordDevs</a>
115
+ </p>
242
116
 
243
- - Repository: https://github.com/worddevs/kira-arts
244
- - Issues: https://github.com/worddevs/kira-arts/issues
117
+ <p align="center">
118
+ <sub>Built with TypeScript and powered by <code>@napi-rs/canvas</code>.</sub>
119
+ </p>