@stella_project/stellalib 1.0.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/LICENSE +213 -0
- package/README.md +285 -0
- package/THIRD-PARTY-NOTICES.md +84 -0
- package/dist/Structures/Filters.d.ts +140 -0
- package/dist/Structures/Filters.d.ts.map +1 -0
- package/dist/Structures/Filters.js +315 -0
- package/dist/Structures/Filters.js.map +1 -0
- package/dist/Structures/LRUCache.d.ts +36 -0
- package/dist/Structures/LRUCache.d.ts.map +1 -0
- package/dist/Structures/LRUCache.js +94 -0
- package/dist/Structures/LRUCache.js.map +1 -0
- package/dist/Structures/Manager.d.ts +146 -0
- package/dist/Structures/Manager.d.ts.map +1 -0
- package/dist/Structures/Manager.js +503 -0
- package/dist/Structures/Manager.js.map +1 -0
- package/dist/Structures/Node.d.ts +118 -0
- package/dist/Structures/Node.d.ts.map +1 -0
- package/dist/Structures/Node.js +927 -0
- package/dist/Structures/Node.js.map +1 -0
- package/dist/Structures/Player.d.ts +193 -0
- package/dist/Structures/Player.d.ts.map +1 -0
- package/dist/Structures/Player.js +598 -0
- package/dist/Structures/Player.js.map +1 -0
- package/dist/Structures/Queue.d.ts +48 -0
- package/dist/Structures/Queue.d.ts.map +1 -0
- package/dist/Structures/Queue.js +114 -0
- package/dist/Structures/Queue.js.map +1 -0
- package/dist/Structures/Rest.d.ts +105 -0
- package/dist/Structures/Rest.d.ts.map +1 -0
- package/dist/Structures/Rest.js +343 -0
- package/dist/Structures/Rest.js.map +1 -0
- package/dist/Structures/SessionStore.d.ts +42 -0
- package/dist/Structures/SessionStore.d.ts.map +1 -0
- package/dist/Structures/SessionStore.js +94 -0
- package/dist/Structures/SessionStore.js.map +1 -0
- package/dist/Structures/Types.d.ts +450 -0
- package/dist/Structures/Types.d.ts.map +1 -0
- package/dist/Structures/Types.js +13 -0
- package/dist/Structures/Types.js.map +1 -0
- package/dist/Structures/Utils.d.ts +61 -0
- package/dist/Structures/Utils.d.ts.map +1 -0
- package/dist/Structures/Utils.js +204 -0
- package/dist/Structures/Utils.js.map +1 -0
- package/dist/Utils/FiltersEqualizers.d.ts +20 -0
- package/dist/Utils/FiltersEqualizers.d.ts.map +1 -0
- package/dist/Utils/FiltersEqualizers.js +96 -0
- package/dist/Utils/FiltersEqualizers.js.map +1 -0
- package/dist/Utils/ManagerCheck.d.ts +9 -0
- package/dist/Utils/ManagerCheck.d.ts.map +1 -0
- package/dist/Utils/ManagerCheck.js +45 -0
- package/dist/Utils/ManagerCheck.js.map +1 -0
- package/dist/Utils/NodeCheck.d.ts +9 -0
- package/dist/Utils/NodeCheck.d.ts.map +1 -0
- package/dist/Utils/NodeCheck.js +31 -0
- package/dist/Utils/NodeCheck.js.map +1 -0
- package/dist/Utils/PlayerCheck.d.ts +9 -0
- package/dist/Utils/PlayerCheck.d.ts.map +1 -0
- package/dist/Utils/PlayerCheck.js +23 -0
- package/dist/Utils/PlayerCheck.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Open Software License v. 3.0 (OSL-3.0)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AntonyZ, x2sadddDM, SynX, Astel
|
|
4
|
+
|
|
5
|
+
This Open Software License (the "License") applies to any original work of
|
|
6
|
+
authorship (the "Original Work") whose owner (the "Licensor") has placed the
|
|
7
|
+
following licensing notice adjacent to the copyright notice for the Original
|
|
8
|
+
Work:
|
|
9
|
+
|
|
10
|
+
Licensed under the Open Software License version 3.0
|
|
11
|
+
|
|
12
|
+
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free,
|
|
13
|
+
non-exclusive, sublicensable license, for the duration of the copyright, to do
|
|
14
|
+
the following:
|
|
15
|
+
|
|
16
|
+
a) to reproduce the Original Work in copies, either alone or as part of a
|
|
17
|
+
collective work;
|
|
18
|
+
b) to translate, adapt, alter, transform, modify, or arrange the Original
|
|
19
|
+
Work, thereby creating derivative works ("Derivative Works") based upon
|
|
20
|
+
the Original Work;
|
|
21
|
+
c) to distribute or communicate copies of the Original Work and Derivative
|
|
22
|
+
Works to the public, with the proviso that copies of Original Work or
|
|
23
|
+
Derivative Works that You distribute or communicate shall be licensed
|
|
24
|
+
under this Open Software License;
|
|
25
|
+
d) to perform the Original Work publicly; and
|
|
26
|
+
e) to display the Original Work publicly.
|
|
27
|
+
|
|
28
|
+
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free,
|
|
29
|
+
non-exclusive, sublicensable license, under patent claims owned or controlled
|
|
30
|
+
by the Licensor that are embodied in the Original Work as furnished by the
|
|
31
|
+
Licensor, for the duration of the patents, to make, use, sell, offer for sale,
|
|
32
|
+
have made, and import the Original Work and Derivative Works.
|
|
33
|
+
|
|
34
|
+
3) Grant of Source Code License. The term "Source Code" means the preferred
|
|
35
|
+
form of the Original Work for making modifications to it and all available
|
|
36
|
+
documentation describing how to modify the Original Work. Licensor agrees to
|
|
37
|
+
provide a machine-readable copy of the Source Code of the Original Work along
|
|
38
|
+
with each copy of the Original Work that Licensor distributes. Licensor
|
|
39
|
+
reserves the right to satisfy this obligation by placing a machine-readable
|
|
40
|
+
copy of the Source Code in an information repository reasonably calculated to
|
|
41
|
+
permit inexpensive and convenient access by You for as long as Licensor
|
|
42
|
+
continues to distribute the Original Work.
|
|
43
|
+
|
|
44
|
+
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
|
|
45
|
+
of any contributors to the Original Work, nor any of their trademarks or
|
|
46
|
+
service marks, may be used to endorse or promote products derived from this
|
|
47
|
+
Original Work without express prior permission of the Licensor. Except as
|
|
48
|
+
expressly stated herein, nothing in this License grants any license to
|
|
49
|
+
Licensor's trademarks, copyrights, patents, trade secrets or any other
|
|
50
|
+
intellectual property. No patent license is granted to make, use, sell, offer
|
|
51
|
+
for sale, have made, or import embodiments of any patent claims other than the
|
|
52
|
+
licensed claims defined in Section 2. No license is granted to the trademarks
|
|
53
|
+
of Licensor even if such marks are included in the Original Work. Nothing in
|
|
54
|
+
this License shall be interpreted to prohibit Licensor from licensing under
|
|
55
|
+
terms different from this License any Original Work that Licensor otherwise
|
|
56
|
+
would have a right to license.
|
|
57
|
+
|
|
58
|
+
5) External Deployment. The term "External Deployment" means the use,
|
|
59
|
+
distribution, or communication of the Original Work or Derivative Works in any
|
|
60
|
+
way such that the Original Work or Derivative Works may be used by anyone
|
|
61
|
+
other than You, whether those works are distributed or communicated to those
|
|
62
|
+
persons or made available as an application intended for use over a network.
|
|
63
|
+
As an express condition for the grants of license hereunder, You must treat
|
|
64
|
+
any External Deployment by You of the Original Work or a Derivative Work as a
|
|
65
|
+
distribution under section 1(c).
|
|
66
|
+
|
|
67
|
+
6) Attribution Rights. You must retain, in the Source Code of any Derivative
|
|
68
|
+
Works that You create, all copyright, patent, or trademark notices from the
|
|
69
|
+
Source Code of the Original Work, as well as any notices of licensing and any
|
|
70
|
+
descriptive text identified therein as an "Attribution Notice." You must cause
|
|
71
|
+
the Source Code for any Derivative Works that You create to carry a prominent
|
|
72
|
+
Attribution Notice reasonably calculated to inform recipients that You have
|
|
73
|
+
modified the Original Work.
|
|
74
|
+
|
|
75
|
+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
|
|
76
|
+
the copyright in and to the Original Work and the patent rights granted herein
|
|
77
|
+
by Licensor are owned by the Licensor or are sublicensed to You under the
|
|
78
|
+
terms of this License with the permission of the contributor(s) of those
|
|
79
|
+
copyrights and patent rights. Except as expressly stated in the immediately
|
|
80
|
+
preceding sentence, the Original Work is provided under this License on an
|
|
81
|
+
"AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including,
|
|
82
|
+
without limitation, the warranties of non-infringement, merchantability or
|
|
83
|
+
fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE
|
|
84
|
+
ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an
|
|
85
|
+
essential part of this License. No license to the Original Work is granted by
|
|
86
|
+
this License except under this disclaimer.
|
|
87
|
+
|
|
88
|
+
8) Limitation of Liability. Under no circumstances and under no legal theory,
|
|
89
|
+
whether in tort (including negligence), contract, or otherwise, shall the
|
|
90
|
+
Licensor be liable to anyone for any indirect, special, incidental, or
|
|
91
|
+
consequential damages of any character arising as a result of this License or
|
|
92
|
+
the use of the Original Work including, without limitation, damages for loss
|
|
93
|
+
of goodwill, work stoppage, computer failure or malfunction, or any and all
|
|
94
|
+
other commercial damages or losses. This limitation of liability shall not
|
|
95
|
+
apply to the extent applicable law prohibits such limitation.
|
|
96
|
+
|
|
97
|
+
9) Acceptance and Termination. If, at any time, You expressly assented to
|
|
98
|
+
this License, that assent indicates your clear and irrevocable acceptance of
|
|
99
|
+
this License and all of its terms and conditions. If You distribute or
|
|
100
|
+
communicate copies of the Original Work or a Derivative Work, You must make a
|
|
101
|
+
reasonable effort under the circumstances to obtain the express assent of
|
|
102
|
+
recipients to the terms of this License. This License conditions your rights
|
|
103
|
+
to undertake the activities listed in Section 1, including your right to
|
|
104
|
+
create Derivative Works based upon the Original Work, and doing so without
|
|
105
|
+
honoring these terms and conditions is prohibited by copyright law and
|
|
106
|
+
international treaty. Nothing in this License is intended to affect copyright
|
|
107
|
+
exceptions and limitations (including "fair use" or "fair dealing"). This
|
|
108
|
+
License shall terminate immediately and You may no longer exercise any of the
|
|
109
|
+
rights granted to You by this License upon your failure to honor the
|
|
110
|
+
conditions in Section 1(c).
|
|
111
|
+
|
|
112
|
+
10) Termination for Patent Action. This License shall terminate automatically
|
|
113
|
+
and You may no longer exercise any of the rights granted to You by this
|
|
114
|
+
License as of the date You commence an action, including a cross-claim or
|
|
115
|
+
counterclaim, against Licensor or any licensee alleging that the Original Work
|
|
116
|
+
infringes a patent. This termination provision shall not apply for an action
|
|
117
|
+
alleging patent infringement by combinations of the Original Work with other
|
|
118
|
+
software or hardware.
|
|
119
|
+
|
|
120
|
+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
|
|
121
|
+
License may be brought only in the courts of a jurisdiction wherein the
|
|
122
|
+
Licensor resides or in which Licensor conducts its primary business, and under
|
|
123
|
+
the laws of that jurisdiction excluding its conflict-of-law provisions. The
|
|
124
|
+
application of the United Nations Convention on Contracts for the
|
|
125
|
+
International Sale of Goods is expressly excluded. Any use of the Original
|
|
126
|
+
Work outside the scope of this License or after its termination shall be
|
|
127
|
+
subject to the requirements and penalties of copyright or patent law in the
|
|
128
|
+
appropriate jurisdiction. This section shall survive the termination of this
|
|
129
|
+
License.
|
|
130
|
+
|
|
131
|
+
12) Attorneys' Fees. In any action to enforce the terms of this License or
|
|
132
|
+
seeking damages relating thereto, the prevailing party shall be entitled to
|
|
133
|
+
recover its costs and expenses, including, without limitation, reasonable
|
|
134
|
+
attorneys' fees and costs incurred in connection with such action, including
|
|
135
|
+
any appeal of such action. This section shall survive the termination of this
|
|
136
|
+
License.
|
|
137
|
+
|
|
138
|
+
13) Miscellaneous. If any provision of this License is held to be
|
|
139
|
+
unenforceable, such provision shall be reformed only to the extent necessary
|
|
140
|
+
to make it enforceable.
|
|
141
|
+
|
|
142
|
+
14) Definition of "You" in This License. "You" throughout this License,
|
|
143
|
+
whether in upper or lower case, means an individual or a legal entity
|
|
144
|
+
exercising rights under, and complying with all of the terms of, this License.
|
|
145
|
+
For legal entities, "You" includes any entity that controls, is controlled by,
|
|
146
|
+
or is under common control with you. For purposes of this definition,
|
|
147
|
+
"control" means (i) the power, direct or indirect, to cause the direction or
|
|
148
|
+
management of such entity, whether by contract or otherwise, or (ii) ownership
|
|
149
|
+
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
|
150
|
+
ownership of such entity.
|
|
151
|
+
|
|
152
|
+
15) Right to Use. You may use the Original Work in all ways not otherwise
|
|
153
|
+
restricted or conditioned by this License or by law, and Licensor promises not
|
|
154
|
+
to interfere with or be responsible for such uses by You.
|
|
155
|
+
|
|
156
|
+
16) Modification of This License. This License is Copyright (c) 2005 Lawrence
|
|
157
|
+
Rosen. Permission is granted to copy, distribute, or communicate this License
|
|
158
|
+
without modification. Nothing in this License permits You to modify this
|
|
159
|
+
License as applied to the Original Work or to Derivative Works. However, You
|
|
160
|
+
may modify the text of this License and copy, distribute or communicate your
|
|
161
|
+
modified version (the "Modified License") and apply it to other original works
|
|
162
|
+
of authorship subject to the following conditions: (i) You may not indicate in
|
|
163
|
+
any way that your Modified License is the "Open Software License" or "OSL"
|
|
164
|
+
and you may not use those names in the name of your Modified License;
|
|
165
|
+
(ii) You must replace the notice specified in the first paragraph above with
|
|
166
|
+
the notice "Licensed under <insert your license name here>" or with a notice
|
|
167
|
+
of your own that is not confusingly similar to the notice in this License; and
|
|
168
|
+
(iii) You may not claim that your original works are open source software
|
|
169
|
+
unless your Modified License has been approved by Open Source Initiative (OSI)
|
|
170
|
+
and You comply with its license review and certification process.
|
|
171
|
+
|
|
172
|
+
================================================================================
|
|
173
|
+
|
|
174
|
+
NOTICE — UPSTREAM DERIVATIVE WORK
|
|
175
|
+
|
|
176
|
+
This software, StellaLib, is a derivative work based in part on LithiumX.
|
|
177
|
+
The original LithiumX source code is Copyright (c) 2025 Anantix Network and
|
|
178
|
+
was released under the MIT License. In compliance with the MIT License, the
|
|
179
|
+
original copyright notice and permission notice are reproduced below.
|
|
180
|
+
|
|
181
|
+
StellaLib as a whole is licensed under the Open Software License v3.0 (above).
|
|
182
|
+
However, the portions derived from LithiumX remain available under the
|
|
183
|
+
original MIT License terms. Recipients of this software receive rights under
|
|
184
|
+
BOTH licenses: the OSL-3.0 for the StellaLib original contributions and the
|
|
185
|
+
MIT License for the LithiumX-derived portions.
|
|
186
|
+
|
|
187
|
+
See THIRD-PARTY-NOTICES.md for the full upstream license text and details of
|
|
188
|
+
which components are derived from LithiumX.
|
|
189
|
+
|
|
190
|
+
--------------------------------------------------------------------------------
|
|
191
|
+
|
|
192
|
+
MIT License
|
|
193
|
+
|
|
194
|
+
Copyright (c) 2025 Anantix Network
|
|
195
|
+
https://github.com/anantix-network/LithiumX
|
|
196
|
+
|
|
197
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
198
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
199
|
+
in the Software without restriction, including without limitation the rights
|
|
200
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
201
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
202
|
+
furnished to do so, subject to the following conditions:
|
|
203
|
+
|
|
204
|
+
The above copyright notice and this permission notice shall be included in all
|
|
205
|
+
copies or substantial portions of the Software.
|
|
206
|
+
|
|
207
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
208
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
209
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
210
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
211
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
212
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
213
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# StellaLib
|
|
2
|
+
|
|
3
|
+
A powerful, modern Lavalink client library for TypeScript/JavaScript with auto version detection (v3 + v4), session persistence, smart autoplay, and graceful shutdown.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/stellalib)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Lavalink v3 + v4** — Auto-detects server version and adapts protocol automatically
|
|
11
|
+
- **Session Persistence** — Save/restore session IDs across bot restarts with `FileSessionStore`
|
|
12
|
+
- **Smart Autoplay** — Auto-mix engine with transition scoring, multi-seed recommendations, and history tracking
|
|
13
|
+
- **Graceful Shutdown** — Persist sessions, close nodes cleanly, and flush stores on SIGINT/SIGTERM
|
|
14
|
+
- **Voice Readiness** — Promise-based voice connection waiting before playback
|
|
15
|
+
- **Audio Filters** — Built-in presets: bassboost, nightcore, vaporwave, 8D, slowmo, and more
|
|
16
|
+
- **Search Caching** — LRU cache with TTL for search results to reduce API calls
|
|
17
|
+
- **Search Fallback** — Automatic fallback across platforms (Spotify → SoundCloud → YouTube)
|
|
18
|
+
- **Node Selection** — Penalty-based, least-load, least-players, or priority-based node selection
|
|
19
|
+
- **Heartbeat** — WebSocket ping/pong to detect dead connections and auto-reconnect
|
|
20
|
+
- **REST Resilience** — Auto-retry on 429 rate limits, GET deduplication, request timeouts
|
|
21
|
+
- **Reconnect** — Exponential backoff with jitter to prevent thundering herd
|
|
22
|
+
- **Plugin System** — Extensible via plugins
|
|
23
|
+
- **Typed Events** — Fully typed event emitter for all manager events
|
|
24
|
+
- **Strict TypeScript** — Written with strict TypeScript
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install stellalib
|
|
30
|
+
# or
|
|
31
|
+
yarn add stellalib
|
|
32
|
+
# or
|
|
33
|
+
bun add stellalib
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Client, GatewayIntentBits } from "discord.js";
|
|
40
|
+
import { StellaManager, FileSessionStore } from "stellalib";
|
|
41
|
+
|
|
42
|
+
const client = new Client({
|
|
43
|
+
intents: [
|
|
44
|
+
GatewayIntentBits.Guilds,
|
|
45
|
+
GatewayIntentBits.GuildVoiceStates,
|
|
46
|
+
GatewayIntentBits.GuildMessages,
|
|
47
|
+
GatewayIntentBits.MessageContent,
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const manager = new StellaManager({
|
|
52
|
+
nodes: [
|
|
53
|
+
{
|
|
54
|
+
identifier: "main",
|
|
55
|
+
host: "localhost",
|
|
56
|
+
port: 2333,
|
|
57
|
+
password: "youshallnotpass",
|
|
58
|
+
resumeStatus: true,
|
|
59
|
+
resumeTimeout: 120,
|
|
60
|
+
heartbeatInterval: 30000,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
autoPlay: true,
|
|
64
|
+
defaultSearchPlatform: "spotify",
|
|
65
|
+
searchFallback: ["soundcloud", "youtube music", "youtube"],
|
|
66
|
+
sessionStore: new FileSessionStore("./sessions.json"),
|
|
67
|
+
caches: { enabled: true, time: 60000, maxSize: 200 },
|
|
68
|
+
send(id, payload) {
|
|
69
|
+
const guild = client.guilds.cache.get(id);
|
|
70
|
+
if (guild) guild.shard.send(payload);
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Forward raw Discord events to StellaLib
|
|
75
|
+
client.on("raw", (d) => manager.updateVoiceState(d));
|
|
76
|
+
|
|
77
|
+
client.on("ready", () => {
|
|
78
|
+
console.log(`Bot ready as ${client.user?.tag}`);
|
|
79
|
+
manager.init(client.user!.id);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Graceful shutdown
|
|
83
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
84
|
+
process.on(sig, async () => {
|
|
85
|
+
await manager.shutdown();
|
|
86
|
+
process.exit(0);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Play a track
|
|
91
|
+
manager.on("NodeConnect", async () => {
|
|
92
|
+
const player = manager.create({
|
|
93
|
+
guild: "GUILD_ID",
|
|
94
|
+
voiceChannel: "VOICE_CHANNEL_ID",
|
|
95
|
+
textChannel: "TEXT_CHANNEL_ID",
|
|
96
|
+
});
|
|
97
|
+
player.connect();
|
|
98
|
+
|
|
99
|
+
const res = await manager.search("never gonna give you up");
|
|
100
|
+
if (res.tracks.length) {
|
|
101
|
+
player.queue.add(res.tracks[0]);
|
|
102
|
+
player.play();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
client.login("YOUR_BOT_TOKEN");
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Session Persistence
|
|
110
|
+
|
|
111
|
+
StellaLib can persist Lavalink session IDs across bot restarts, so players keep playing without interruption:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { FileSessionStore } from "stellalib";
|
|
115
|
+
|
|
116
|
+
const manager = new StellaManager({
|
|
117
|
+
sessionStore: new FileSessionStore("./sessions.json"),
|
|
118
|
+
nodes: [{
|
|
119
|
+
resumeStatus: true,
|
|
120
|
+
resumeTimeout: 120, // seconds Lavalink waits for reconnect
|
|
121
|
+
// ...
|
|
122
|
+
}],
|
|
123
|
+
// ...
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// On shutdown, sessions are saved automatically
|
|
127
|
+
await manager.shutdown();
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
You can also implement your own store (e.g., Redis) by implementing the `SessionStore` interface:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
interface SessionStore {
|
|
134
|
+
get(nodeId: string): Promise<string | null> | string | null;
|
|
135
|
+
set(nodeId: string, sessionId: string): Promise<void> | void;
|
|
136
|
+
delete(nodeId: string): Promise<void> | void;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Smart Autoplay
|
|
141
|
+
|
|
142
|
+
When the queue ends and autoplay is enabled, StellaLib's auto-mix engine finds the best next track:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
// Enable autoplay for a player
|
|
146
|
+
player.setAutoplay(true, { id: user.id, tag: user.tag });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The engine scores candidates based on:
|
|
150
|
+
- **Duration similarity** — Prefer tracks close in length to recent plays
|
|
151
|
+
- **Author/title overlap** — Prioritize same artist or related keywords
|
|
152
|
+
- **Source consistency** — Stay on the same platform when possible
|
|
153
|
+
- **Diversity** — Avoid repeating the same artist too many times
|
|
154
|
+
- **History tracking** — Never replay recently heard tracks (last 50)
|
|
155
|
+
|
|
156
|
+
Uses multi-seed context from the last 5 tracks for Spotify recommendations, theme keyword extraction, and cross-artist transitions.
|
|
157
|
+
|
|
158
|
+
## Search with Fallback
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
const manager = new StellaManager({
|
|
162
|
+
defaultSearchPlatform: "spotify",
|
|
163
|
+
searchFallback: ["soundcloud", "youtube music", "youtube"],
|
|
164
|
+
// ...
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// If Spotify returns empty, automatically tries SoundCloud, then YouTube Music, then YouTube
|
|
168
|
+
const result = await manager.search("natori セレナーデ");
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Audio Filters
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// Toggle filters
|
|
175
|
+
await player.filters.setFilter("nightcore", true);
|
|
176
|
+
await player.filters.setFilter("bassboost", true);
|
|
177
|
+
await player.filters.setFilter("vaporwave", true);
|
|
178
|
+
await player.filters.setFilter("eightD", true);
|
|
179
|
+
|
|
180
|
+
// Clear all filters
|
|
181
|
+
await player.filters.clearFilters();
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Available: `bassboost`, `nightcore`, `vaporwave`, `eightD`, `slowmo`, `soft`, `trebleBass`, `tv`, `distort`
|
|
185
|
+
|
|
186
|
+
## Manager Stats
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
const stats = manager.getStats();
|
|
190
|
+
// { nodes, players, playingPlayers, cacheSize, cacheMemoryEstimate }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Events
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
manager.on("NodeConnect", (node) => { });
|
|
197
|
+
manager.on("NodeDisconnect", (node, reason) => { });
|
|
198
|
+
manager.on("NodeError", (node, error) => { });
|
|
199
|
+
manager.on("NodeReconnect", (node) => { });
|
|
200
|
+
manager.on("NodeRaw", (payload) => { });
|
|
201
|
+
manager.on("TrackStart", (player, track, payload) => { });
|
|
202
|
+
manager.on("TrackEnd", (player, track, payload) => { });
|
|
203
|
+
manager.on("TrackStuck", (player, track, payload) => { });
|
|
204
|
+
manager.on("TrackError", (player, track, payload) => { });
|
|
205
|
+
manager.on("QueueEnd", (player, track, payload) => { });
|
|
206
|
+
manager.on("SocketClosed", (player, payload) => { });
|
|
207
|
+
manager.on("PlayerCreate", (player) => { });
|
|
208
|
+
manager.on("PlayerDestroy", (player) => { });
|
|
209
|
+
manager.on("PlayerMove", (player, oldChannel, newChannel) => { });
|
|
210
|
+
manager.on("PlayerDisconnect", (player, oldChannel) => { });
|
|
211
|
+
manager.on("PlayerStateUpdate", (oldPlayer, newPlayer) => { });
|
|
212
|
+
manager.on("Debug", (message) => { });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Project Structure
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
src/
|
|
219
|
+
Structures/
|
|
220
|
+
Manager.ts — Main hub: manages nodes, players, search, voice updates
|
|
221
|
+
Node.ts — Lavalink node: WebSocket, reconnect, session resume, autoplay
|
|
222
|
+
Player.ts — Guild player: playback, queue, voice readiness, filters
|
|
223
|
+
Queue.ts — Queue: extends Array with add/remove/shuffle
|
|
224
|
+
Rest.ts — REST client with retry, timeout, and deduplication
|
|
225
|
+
Filters.ts — Audio filters and presets
|
|
226
|
+
LRUCache.ts — Bounded LRU cache with TTL
|
|
227
|
+
SessionStore.ts — FileSessionStore for session persistence
|
|
228
|
+
Types.ts — All TypeScript interfaces and types
|
|
229
|
+
Utils.ts — TrackUtils, Structure, Plugin helpers
|
|
230
|
+
Utils/
|
|
231
|
+
FiltersEqualizers.ts — Equalizer band presets
|
|
232
|
+
ManagerCheck.ts — Manager option validation
|
|
233
|
+
NodeCheck.ts — Node option validation
|
|
234
|
+
PlayerCheck.ts — Player option validation
|
|
235
|
+
index.ts — Re-exports everything
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Multi-Version Support
|
|
239
|
+
|
|
240
|
+
StellaLib auto-detects your Lavalink server version on connect and adapts:
|
|
241
|
+
|
|
242
|
+
| Feature | Lavalink v3 | Lavalink v4 |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| **WebSocket URL** | `ws://host:port` | `ws://host:port/v4/websocket` |
|
|
245
|
+
| **Player ops** | WebSocket ops (`play`, `stop`, `pause`, etc.) | REST PATCH |
|
|
246
|
+
| **Session resume** | `Resume-Key` header + WS `configureResuming` | `Session-Id` header + REST PATCH |
|
|
247
|
+
| **Load tracks** | `/loadtracks` (normalized to v4 format) | `/v4/loadtracks` |
|
|
248
|
+
| **Server info** | `/version` | `/v4/info` |
|
|
249
|
+
| **Player sync** | Not available | Full player state sync |
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
// No configuration needed — version is auto-detected
|
|
253
|
+
const manager = new StellaManager({
|
|
254
|
+
nodes: [{ host: "my-v3-server.com", port: 2333 }],
|
|
255
|
+
// ...
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Check detected version after connect
|
|
259
|
+
manager.on("NodeConnect", (node) => {
|
|
260
|
+
console.log(`Connected to Lavalink v${node.version}`); // 3 or 4
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Requirements
|
|
265
|
+
|
|
266
|
+
- **Node.js** >= 18.0.0
|
|
267
|
+
- **Lavalink** v3.x or v4.x
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
**StellaLib** is licensed under the [Open Software License v3.0 (OSL-3.0)](LICENSE).
|
|
272
|
+
|
|
273
|
+
Copyright (c) 2026 AntonyZ, x2sadddDM, SynX, Astel
|
|
274
|
+
|
|
275
|
+
### Upstream License (MIT)
|
|
276
|
+
|
|
277
|
+
StellaLib is a derivative work based on [LithiumX](https://github.com/anantix-network/LithiumX) by Anantix Network. The original LithiumX code is Copyright (c) 2025 Anantix Network and was released under the **MIT License**.
|
|
278
|
+
|
|
279
|
+
In compliance with the MIT License, the original copyright and permission notices are preserved in:
|
|
280
|
+
|
|
281
|
+
- [LICENSE](LICENSE) — Contains both the OSL-3.0 text and the upstream MIT notice
|
|
282
|
+
- [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md) — Full details of derived components and the complete MIT license text
|
|
283
|
+
- Every derived source file carries a `@license` header attributing both copyrights
|
|
284
|
+
|
|
285
|
+
Recipients of this software receive rights under **both** licenses: OSL-3.0 for StellaLib's original contributions, and MIT for the LithiumX-derived portions.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This file contains notices and licenses for third-party software included in
|
|
4
|
+
or used by StellaLib.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## LithiumX
|
|
9
|
+
|
|
10
|
+
- **Project:** LithiumX
|
|
11
|
+
- **Repository:** https://github.com/anantix-network/LithiumX
|
|
12
|
+
- **Copyright:** Copyright (c) 2025 Anantix Network
|
|
13
|
+
- **License:** MIT License
|
|
14
|
+
|
|
15
|
+
### Scope of Derived Work
|
|
16
|
+
|
|
17
|
+
StellaLib's architecture, class structure, and significant portions of its
|
|
18
|
+
source code are derived from LithiumX. The following components contain code
|
|
19
|
+
originally authored by Anantix Network and subsequently modified:
|
|
20
|
+
|
|
21
|
+
| File | Derived From |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `src/Structures/Manager.ts` | `LithiumX/src/Structures/Manager.ts` |
|
|
24
|
+
| `src/Structures/Node.ts` | `LithiumX/src/Structures/Node.ts` |
|
|
25
|
+
| `src/Structures/Player.ts` | `LithiumX/src/Structures/Player.ts` |
|
|
26
|
+
| `src/Structures/Queue.ts` | `LithiumX/src/Structures/Queue.ts` |
|
|
27
|
+
| `src/Structures/Rest.ts` | `LithiumX/src/Structures/Rest.ts` |
|
|
28
|
+
| `src/Structures/Filters.ts` | `LithiumX/src/Structures/Filters.ts` |
|
|
29
|
+
| `src/Structures/Utils.ts` | `LithiumX/src/Structures/Utils.ts` |
|
|
30
|
+
| `src/Structures/Types.ts` | Extracted from multiple LithiumX source files |
|
|
31
|
+
| `src/Utils/FiltersEqualizers.ts` | `LithiumX/src/Utils/FiltersEqualizers.ts` |
|
|
32
|
+
| `src/Utils/ManagerCheck.ts` | `LithiumX/src/Utils/ManagerCheck.ts` |
|
|
33
|
+
| `src/Utils/NodeCheck.ts` | `LithiumX/src/Utils/NodeCheck.ts` |
|
|
34
|
+
| `src/Utils/PlayerCheck.ts` | `LithiumX/src/Utils/PlayerCheck.ts` |
|
|
35
|
+
|
|
36
|
+
### Modifications Made by StellaLib Authors
|
|
37
|
+
|
|
38
|
+
- Added `channelId` to voice PATCH payloads (Lavalink v4 compliance)
|
|
39
|
+
- Implemented promise-based voice readiness system
|
|
40
|
+
- Added session resume with `Session-Id` header and player state sync
|
|
41
|
+
- Replaced `@discordjs/collection` with native `Map` iteration
|
|
42
|
+
- Added exponential backoff on WebSocket reconnect
|
|
43
|
+
- Extracted shared types into `Types.ts` to eliminate circular dependencies
|
|
44
|
+
- Added `Debug` event for internal logging
|
|
45
|
+
- Improved error handling to prevent unhandled promise rejections
|
|
46
|
+
- Added search result caching
|
|
47
|
+
|
|
48
|
+
### Full MIT License Text
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
MIT License
|
|
52
|
+
|
|
53
|
+
Copyright (c) 2025 Anantix Network
|
|
54
|
+
|
|
55
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
56
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
57
|
+
in the Software without restriction, including without limitation the rights
|
|
58
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
59
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
60
|
+
furnished to do so, subject to the following conditions:
|
|
61
|
+
|
|
62
|
+
The above copyright notice and this permission notice shall be included in all
|
|
63
|
+
copies or substantial portions of the Software.
|
|
64
|
+
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
68
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
69
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
70
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
71
|
+
SOFTWARE.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## tiny-typed-emitter
|
|
77
|
+
|
|
78
|
+
- **Repository:** https://github.com/binier/tiny-typed-emitter
|
|
79
|
+
- **License:** MIT License
|
|
80
|
+
|
|
81
|
+
## ws
|
|
82
|
+
|
|
83
|
+
- **Repository:** https://github.com/websockets/ws
|
|
84
|
+
- **License:** MIT License
|