kira-arts 1.1.1 โ 1.2.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 +66 -9
- package/dist/index.cjs +582 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +161 -53
- package/dist/index.d.ts +161 -53
- package/dist/index.js +576 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
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
|
|
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
|
[](https://www.npmjs.com/package/kira-arts)
|
|
6
|
+
[](https://www.npmjs.com/package/kira-arts)
|
|
7
|
+
[](https://packagephobia.com/result?p=kira-arts)
|
|
6
8
|
[](./LICENSE)
|
|
9
|
+
[](https://www.npmjs.com/package/kira-arts)
|
|
10
|
+
[](./dist/index.d.ts)
|
|
11
|
+
[](https://www.typescriptlang.org/)
|
|
12
|
+
[](https://github.com/worddevs/kira-arts/actions/workflows/tests.yml)
|
|
13
|
+
[](https://github.com/worddevs/kira-arts/actions/workflows/release.yml)
|
|
14
|
+
[](https://github.com/worddevs/kira-arts/stargazers)
|
|
15
|
+
[](https://github.com/worddevs/kira-arts/network/members)
|
|
16
|
+
[](https://github.com/worddevs/kira-arts/graphs/contributors)
|
|
17
|
+
[](https://github.com/worddevs/kira-arts/commits/main)
|
|
18
|
+
[](https://github.com/worddevs/kira-arts/issues)
|
|
19
|
+
[](./CONTRIBUTING.md)
|
|
20
|
+
[](https://github.com/prettier/prettier)
|
|
7
21
|
|
|
8
22
|
## โจ Features
|
|
9
23
|
|
|
@@ -13,25 +27,20 @@ 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
|
-
```
|
|
37
|
+
```cmd
|
|
23
38
|
npm install kira-arts
|
|
24
|
-
```
|
|
25
39
|
|
|
26
|
-
```bash
|
|
27
40
|
pnpm add kira-arts
|
|
28
|
-
```
|
|
29
41
|
|
|
30
|
-
```bash
|
|
31
42
|
yarn add kira-arts
|
|
32
|
-
```
|
|
33
43
|
|
|
34
|
-
```bash
|
|
35
44
|
bun add kira-arts
|
|
36
45
|
```
|
|
37
46
|
|
|
@@ -129,6 +138,54 @@ const buffer = await shipImage(userIdA, userIdB, {
|
|
|
129
138
|
});
|
|
130
139
|
```
|
|
131
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
|
+
|
|
132
189
|
## ๐จ Available themes
|
|
133
190
|
|
|
134
191
|
```
|