kira-arts 1.1.0 โ†’ 1.2.0

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
@@ -1,9 +1,23 @@
1
- # kira-arts ๐Ÿซ
1
+ # kira-arts ๐Ÿ’ž
2
2
 
3
- A TypeScript library for generating Discord-style visual cards: profiles, welcome/leave events, level-up, achievements, leaderboards, and compatibility "ship" cards โ€” powered by `@napi-rs/canvas`.
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
5
  [![npm version](https://img.shields.io/npm/v/kira-arts.svg)](https://www.npmjs.com/package/kira-arts)
6
+ [![npm downloads](https://img.shields.io/npm/dm/kira-arts.svg)](https://www.npmjs.com/package/kira-arts)
7
+ [![install size](https://packagephobia.com/badge?p=kira-arts)](https://packagephobia.com/result?p=kira-arts)
6
8
  [![license](https://img.shields.io/npm/l/kira-arts.svg)](./LICENSE)
9
+ [![node](https://img.shields.io/node/v/kira-arts.svg)](https://www.npmjs.com/package/kira-arts)
10
+ [![types](https://img.shields.io/npm/types/kira-arts.svg)](./dist/index.d.ts)
11
+ [![TypeScript](https://img.shields.io/badge/built_with-TypeScript-3178c6.svg)](https://www.typescriptlang.org/)
12
+ [![tests](https://github.com/worddevs/kira-arts/actions/workflows/tests.yml/badge.svg)](https://github.com/worddevs/kira-arts/actions/workflows/tests.yml)
13
+ [![release](https://github.com/worddevs/kira-arts/actions/workflows/release.yml/badge.svg)](https://github.com/worddevs/kira-arts/actions/workflows/release.yml)
14
+ [![GitHub stars](https://img.shields.io/github/stars/worddevs/kira-arts.svg?style=flat)](https://github.com/worddevs/kira-arts/stargazers)
15
+ [![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)
17
+ [![last commit](https://img.shields.io/github/last-commit/worddevs/kira-arts.svg)](https://github.com/worddevs/kira-arts/commits/main)
18
+ [![open issues](https://img.shields.io/github/issues/worddevs/kira-arts.svg)](https://github.com/worddevs/kira-arts/issues)
19
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)
20
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
7
21
 
8
22
  ## โœจ Features
9
23
 
@@ -13,14 +27,21 @@ A TypeScript library for generating Discord-style visual cards: profiles, welcom
13
27
  - ๐Ÿ† **Achievement Card** โ€” achievement card with rarity (`common`, `rare`, `epic`, `legendary`).
14
28
  - ๐Ÿ… **Leaderboard Card** โ€” ranking table with up to 15 entries.
15
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.
16
31
  - ๐ŸŽจ **Built-in themes**: `discord`, `midnight`, `sunset`, `neon`, `forest`, `sakura`, `monochrome`, `gold`.
17
32
  - ๐Ÿ—ƒ๏ธ Configurable internal cache for user data.
18
33
  - ๐Ÿงพ Output as `png`, `jpeg`, or `webp`, ready to use as a discord.js `AttachmentBuilder`.
19
34
 
20
35
  ## ๐Ÿ“ฆ Installation
21
36
 
22
- ```bash
37
+ ```cmd
23
38
  npm install kira-arts
39
+
40
+ pnpm add kira-arts
41
+
42
+ yarn add kira-arts
43
+
44
+ bun add kira-arts
24
45
  ```
25
46
 
26
47
  > Requires Node.js >= 20 and a project with `discord.js` ^14.27.0 already installed (peer dependency).
@@ -117,6 +138,54 @@ const buffer = await shipImage(userIdA, userIdB, {
117
138
  });
118
139
  ```
119
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),
175
+ });
176
+
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
+
120
189
  ## ๐ŸŽจ Available themes
121
190
 
122
191
  ```