hoshimi 0.3.1 → 0.3.3

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/dist/index.d.mts CHANGED
@@ -1738,6 +1738,11 @@ declare class FilterManager {
1738
1738
  * @returns {Promise<this>} The instance of the filter manager.
1739
1739
  */
1740
1740
  setTimescale(settings: Partial<TimescaleSettings>): Promise<this>;
1741
+ /**
1742
+ * Convert the filter settings to a JSON object.
1743
+ * @returns {FilterSettings} The filter settings as a JSON object.
1744
+ */
1745
+ toJSON(): FilterSettings;
1741
1746
  }
1742
1747
 
1743
1748
  /**
@@ -1916,10 +1921,21 @@ declare class Player {
1916
1921
  */
1917
1922
  createdTimestamp: number;
1918
1923
  /**
1919
- * The position of the player.
1924
+ * The last position received from Lavalink.
1920
1925
  * @type {number}
1921
1926
  */
1922
- position: number;
1927
+ lastPosition: number;
1928
+ /**
1929
+ * The timestamp when the last position change update happened.
1930
+ * @type {number | null}
1931
+ */
1932
+ lastPositionUpdate: number | null;
1933
+ /**
1934
+ * The current calculated position of the player.
1935
+ * @type {number}
1936
+ * @readonly
1937
+ */
1938
+ get position(): number;
1923
1939
  /**
1924
1940
  * The voice connection details.
1925
1941
  * @type {PlayerVoice}
@@ -3266,16 +3282,46 @@ interface PlayerJson {
3266
3282
  * @type {string | undefined}
3267
3283
  */
3268
3284
  textId?: string;
3285
+ /**
3286
+ * The last position received from Lavalink.
3287
+ * @type {number}
3288
+ */
3289
+ lastPosition: number;
3290
+ /**
3291
+ * The timestamp when the last position change update happened.
3292
+ * @type {number | null}
3293
+ */
3294
+ lastPositionUpdate: number | null;
3295
+ /**
3296
+ * The current calculated position of the player.
3297
+ * @type {number}
3298
+ */
3299
+ position: number;
3300
+ /**
3301
+ * The timestamp when the player was created.
3302
+ * @type {number}
3303
+ */
3304
+ createdTimestamp: number;
3305
+ /**
3306
+ * The ping of the player.
3307
+ * @type {number}
3308
+ */
3309
+ ping: number;
3269
3310
  /**
3270
3311
  * The queue of the player.
3271
- * @type {QueueJson | undefined}
3312
+ * @type {QueueJson}
3272
3313
  */
3273
- queue?: QueueJson;
3314
+ queue: QueueJson;
3274
3315
  /**
3275
3316
  * The node of the player.
3276
- * @type {NodeJson | undefined}
3317
+ * @type {NodeJson}
3277
3318
  */
3278
- node?: NodeJson;
3319
+ node: NodeJson;
3320
+ /**
3321
+ * The filter settings of the player.
3322
+ * @type {FilterSettings}
3323
+ */
3324
+ filters: FilterSettings;
3279
3325
  }
3280
3326
  /**
3281
3327
  * The lyrics methods for the player.
package/dist/index.d.ts CHANGED
@@ -1738,6 +1738,11 @@ declare class FilterManager {
1738
1738
  * @returns {Promise<this>} The instance of the filter manager.
1739
1739
  */
1740
1740
  setTimescale(settings: Partial<TimescaleSettings>): Promise<this>;
1741
+ /**
1742
+ * Convert the filter settings to a JSON object.
1743
+ * @returns {FilterSettings} The filter settings as a JSON object.
1744
+ */
1745
+ toJSON(): FilterSettings;
1741
1746
  }
1742
1747
 
1743
1748
  /**
@@ -1916,10 +1921,21 @@ declare class Player {
1916
1921
  */
1917
1922
  createdTimestamp: number;
1918
1923
  /**
1919
- * The position of the player.
1924
+ * The last position received from Lavalink.
1920
1925
  * @type {number}
1921
1926
  */
1922
- position: number;
1927
+ lastPosition: number;
1928
+ /**
1929
+ * The timestamp when the last position change update happened.
1930
+ * @type {number | null}
1931
+ */
1932
+ lastPositionUpdate: number | null;
1933
+ /**
1934
+ * The current calculated position of the player.
1935
+ * @type {number}
1936
+ * @readonly
1937
+ */
1938
+ get position(): number;
1923
1939
  /**
1924
1940
  * The voice connection details.
1925
1941
  * @type {PlayerVoice}
@@ -3266,16 +3282,46 @@ interface PlayerJson {
3266
3282
  * @type {string | undefined}
3267
3283
  */
3268
3284
  textId?: string;
3285
+ /**
3286
+ * The last position received from Lavalink.
3287
+ * @type {number}
3288
+ */
3289
+ lastPosition: number;
3290
+ /**
3291
+ * The timestamp when the last position change update happened.
3292
+ * @type {number | null}
3293
+ */
3294
+ lastPositionUpdate: number | null;
3295
+ /**
3296
+ * The current calculated position of the player.
3297
+ * @type {number}
3298
+ */
3299
+ position: number;
3300
+ /**
3301
+ * The timestamp when the player was created.
3302
+ * @type {number}
3303
+ */
3304
+ createdTimestamp: number;
3305
+ /**
3306
+ * The ping of the player.
3307
+ * @type {number}
3308
+ */
3309
+ ping: number;
3269
3310
  /**
3270
3311
  * The queue of the player.
3271
- * @type {QueueJson | undefined}
3312
+ * @type {QueueJson}
3272
3313
  */
3273
- queue?: QueueJson;
3314
+ queue: QueueJson;
3274
3315
  /**
3275
3316
  * The node of the player.
3276
- * @type {NodeJson | undefined}
3317
+ * @type {NodeJson}
3277
3318
  */
3278
- node?: NodeJson;
3319
+ node: NodeJson;
3320
+ /**
3321
+ * The filter settings of the player.
3322
+ * @type {FilterSettings}
3323
+ */
3324
+ filters: FilterSettings;
3279
3325
  }
3280
3326
  /**
3281
3327
  * The lyrics methods for the player.
package/dist/index.js CHANGED
@@ -531,12 +531,12 @@ var UnresolvedTrack = class {
531
531
  // package.json
532
532
  var package_default = {
533
533
  name: "hoshimi",
534
- version: "0.3.1",
534
+ version: "0.3.3",
535
535
  description: "A lavalink@v4 client easy to use, up-to-date and all ears.",
536
536
  main: "./dist/index.js",
537
537
  module: "./dist/index.mjs",
538
538
  types: "./dist/index.d.ts",
539
- packageManager: "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
539
+ packageManager: "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501",
540
540
  files: [
541
541
  "dist"
542
542
  ],
@@ -573,7 +573,7 @@ var package_default = {
573
573
  license: "MIT",
574
574
  devDependencies: {
575
575
  "@biomejs/biome": "^2.3.8",
576
- "@types/node": "^24.10.1",
576
+ "@types/node": "^25.0.1",
577
577
  "@types/ws": "^8.18.1",
578
578
  husky: "^9.1.7",
579
579
  "lint-staged": "^16.2.7",
@@ -818,7 +818,10 @@ function validatePlayerData(data) {
818
818
  player.playing = !data.playerOptions.paused;
819
819
  }
820
820
  if (typeof data.playerOptions.volume === "number") player.volume = data.playerOptions.volume;
821
- if (typeof data.playerOptions.position === "number") player.position = data.playerOptions.position;
821
+ if (typeof data.playerOptions.position === "number") {
822
+ player.lastPosition = data.playerOptions.position;
823
+ player.lastPositionUpdate = Date.now();
824
+ }
822
825
  }
823
826
  }
824
827
  function validateNodePlugins(node, plugins) {
@@ -1492,7 +1495,8 @@ async function playerUpdate(payload) {
1492
1495
  player.ping = payload.state.ping;
1493
1496
  player.connected = payload.state.connected;
1494
1497
  player.createdTimestamp = payload.state.time;
1495
- player.position = payload.state.position;
1498
+ player.lastPosition = payload.state.position || 0;
1499
+ player.lastPositionUpdate = Date.now();
1496
1500
  this.nodeManager.manager.emit("playerUpdate" /* PlayerUpdate */, player, oldPlayer, payload);
1497
1501
  this.nodeManager.manager.emit(
1498
1502
  "debug" /* Debug */,
@@ -3005,6 +3009,13 @@ var FilterManager = class {
3005
3009
  this.filters.timescale = !this.filters.timescale;
3006
3010
  return this.apply();
3007
3011
  }
3012
+ /**
3013
+ * Convert the filter settings to a JSON object.
3014
+ * @returns {FilterSettings} The filter settings as a JSON object.
3015
+ */
3016
+ toJSON() {
3017
+ return { ...this.data };
3018
+ }
3008
3019
  };
3009
3020
 
3010
3021
  // src/classes/player/Storage.ts
@@ -3197,10 +3208,23 @@ var Player = class {
3197
3208
  */
3198
3209
  createdTimestamp = 0;
3199
3210
  /**
3200
- * The position of the player.
3211
+ * The last position received from Lavalink.
3212
+ * @type {number}
3213
+ */
3214
+ lastPosition = 0;
3215
+ /**
3216
+ * The timestamp when the last position change update happened.
3217
+ * @type {number | null}
3218
+ */
3219
+ lastPositionUpdate = null;
3220
+ /**
3221
+ * The current calculated position of the player.
3201
3222
  * @type {number}
3223
+ * @readonly
3202
3224
  */
3203
- position = 0;
3225
+ get position() {
3226
+ return this.lastPosition + (this.lastPositionUpdate ? Date.now() - this.lastPositionUpdate : 0);
3227
+ }
3204
3228
  /**
3205
3229
  * The voice connection details.
3206
3230
  * @type {PlayerVoice}
@@ -3322,6 +3346,8 @@ var Player = class {
3322
3346
  if (typeof position !== "number" || Number.isNaN(position) || position < 0)
3323
3347
  throw new PlayerError("Position must be a positive number.");
3324
3348
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Seek] Seeking to ${position} for guild: ${this.guildId}`);
3349
+ this.lastPosition = position;
3350
+ this.lastPositionUpdate = Date.now();
3325
3351
  await this.updatePlayer({ playerOptions: { position } });
3326
3352
  }
3327
3353
  /**
@@ -3395,10 +3421,15 @@ var Player = class {
3395
3421
  if (!isTrack(this.queue.current) && !isUnresolvedTrack(this.queue.current))
3396
3422
  throw new PlayerError("The track must be a valid Track or UnresolvedTrack instance.");
3397
3423
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Play] A new track is playing: ${this.queue.current.info.title}`);
3424
+ const position = options.position ?? 0;
3425
+ this.lastPosition = position;
3426
+ this.lastPositionUpdate = Date.now();
3398
3427
  await this.updatePlayer({
3399
3428
  noReplace: options.noReplace,
3400
3429
  playerOptions: {
3401
3430
  ...options,
3431
+ position,
3432
+ // Ensure position is sent to Lavalink
3402
3433
  track: {
3403
3434
  userData: this.queue.current.userData,
3404
3435
  encoded: this.queue.current.encoded
@@ -3448,7 +3479,8 @@ var Player = class {
3448
3479
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Stop] Player stopped for guild: ${this.guildId}`);
3449
3480
  this.playing = false;
3450
3481
  this.paused = false;
3451
- this.position = 0;
3482
+ this.lastPosition = 0;
3483
+ this.lastPositionUpdate = null;
3452
3484
  this.queue.current = null;
3453
3485
  return;
3454
3486
  }
@@ -3468,6 +3500,12 @@ var Player = class {
3468
3500
  3 /* Player */,
3469
3501
  `[Player] -> [Pause] Player is now ${paused ? "paused" : "resumed"} for guild: ${this.guildId}`
3470
3502
  );
3503
+ if (paused) {
3504
+ this.lastPositionUpdate = null;
3505
+ } else {
3506
+ this.lastPosition = this.position;
3507
+ this.lastPositionUpdate = Date.now();
3508
+ }
3471
3509
  await this.updatePlayer({ playerOptions: { paused } });
3472
3510
  return paused;
3473
3511
  }
@@ -3635,6 +3673,13 @@ var Player = class {
3635
3673
  selfDeaf: this.selfDeaf,
3636
3674
  options: this.options,
3637
3675
  voice: this.voice,
3676
+ textId: this.textId,
3677
+ lastPosition: this.lastPosition,
3678
+ lastPositionUpdate: this.lastPositionUpdate,
3679
+ position: this.position,
3680
+ createdTimestamp: this.createdTimestamp,
3681
+ ping: this.ping,
3682
+ filters: this.filterManager.toJSON(),
3638
3683
  queue: this.queue.toJSON(),
3639
3684
  node: this.node.toJSON()
3640
3685
  };
package/dist/index.mjs CHANGED
@@ -464,12 +464,12 @@ var UnresolvedTrack = class {
464
464
  // package.json
465
465
  var package_default = {
466
466
  name: "hoshimi",
467
- version: "0.3.1",
467
+ version: "0.3.3",
468
468
  description: "A lavalink@v4 client easy to use, up-to-date and all ears.",
469
469
  main: "./dist/index.js",
470
470
  module: "./dist/index.mjs",
471
471
  types: "./dist/index.d.ts",
472
- packageManager: "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
472
+ packageManager: "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501",
473
473
  files: [
474
474
  "dist"
475
475
  ],
@@ -506,7 +506,7 @@ var package_default = {
506
506
  license: "MIT",
507
507
  devDependencies: {
508
508
  "@biomejs/biome": "^2.3.8",
509
- "@types/node": "^24.10.1",
509
+ "@types/node": "^25.0.1",
510
510
  "@types/ws": "^8.18.1",
511
511
  husky: "^9.1.7",
512
512
  "lint-staged": "^16.2.7",
@@ -751,7 +751,10 @@ function validatePlayerData(data) {
751
751
  player.playing = !data.playerOptions.paused;
752
752
  }
753
753
  if (typeof data.playerOptions.volume === "number") player.volume = data.playerOptions.volume;
754
- if (typeof data.playerOptions.position === "number") player.position = data.playerOptions.position;
754
+ if (typeof data.playerOptions.position === "number") {
755
+ player.lastPosition = data.playerOptions.position;
756
+ player.lastPositionUpdate = Date.now();
757
+ }
755
758
  }
756
759
  }
757
760
  function validateNodePlugins(node, plugins) {
@@ -1425,7 +1428,8 @@ async function playerUpdate(payload) {
1425
1428
  player.ping = payload.state.ping;
1426
1429
  player.connected = payload.state.connected;
1427
1430
  player.createdTimestamp = payload.state.time;
1428
- player.position = payload.state.position;
1431
+ player.lastPosition = payload.state.position || 0;
1432
+ player.lastPositionUpdate = Date.now();
1429
1433
  this.nodeManager.manager.emit("playerUpdate" /* PlayerUpdate */, player, oldPlayer, payload);
1430
1434
  this.nodeManager.manager.emit(
1431
1435
  "debug" /* Debug */,
@@ -2938,6 +2942,13 @@ var FilterManager = class {
2938
2942
  this.filters.timescale = !this.filters.timescale;
2939
2943
  return this.apply();
2940
2944
  }
2945
+ /**
2946
+ * Convert the filter settings to a JSON object.
2947
+ * @returns {FilterSettings} The filter settings as a JSON object.
2948
+ */
2949
+ toJSON() {
2950
+ return { ...this.data };
2951
+ }
2941
2952
  };
2942
2953
 
2943
2954
  // src/classes/player/Storage.ts
@@ -3130,10 +3141,23 @@ var Player = class {
3130
3141
  */
3131
3142
  createdTimestamp = 0;
3132
3143
  /**
3133
- * The position of the player.
3144
+ * The last position received from Lavalink.
3145
+ * @type {number}
3146
+ */
3147
+ lastPosition = 0;
3148
+ /**
3149
+ * The timestamp when the last position change update happened.
3150
+ * @type {number | null}
3151
+ */
3152
+ lastPositionUpdate = null;
3153
+ /**
3154
+ * The current calculated position of the player.
3134
3155
  * @type {number}
3156
+ * @readonly
3135
3157
  */
3136
- position = 0;
3158
+ get position() {
3159
+ return this.lastPosition + (this.lastPositionUpdate ? Date.now() - this.lastPositionUpdate : 0);
3160
+ }
3137
3161
  /**
3138
3162
  * The voice connection details.
3139
3163
  * @type {PlayerVoice}
@@ -3255,6 +3279,8 @@ var Player = class {
3255
3279
  if (typeof position !== "number" || Number.isNaN(position) || position < 0)
3256
3280
  throw new PlayerError("Position must be a positive number.");
3257
3281
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Seek] Seeking to ${position} for guild: ${this.guildId}`);
3282
+ this.lastPosition = position;
3283
+ this.lastPositionUpdate = Date.now();
3258
3284
  await this.updatePlayer({ playerOptions: { position } });
3259
3285
  }
3260
3286
  /**
@@ -3328,10 +3354,15 @@ var Player = class {
3328
3354
  if (!isTrack(this.queue.current) && !isUnresolvedTrack(this.queue.current))
3329
3355
  throw new PlayerError("The track must be a valid Track or UnresolvedTrack instance.");
3330
3356
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Play] A new track is playing: ${this.queue.current.info.title}`);
3357
+ const position = options.position ?? 0;
3358
+ this.lastPosition = position;
3359
+ this.lastPositionUpdate = Date.now();
3331
3360
  await this.updatePlayer({
3332
3361
  noReplace: options.noReplace,
3333
3362
  playerOptions: {
3334
3363
  ...options,
3364
+ position,
3365
+ // Ensure position is sent to Lavalink
3335
3366
  track: {
3336
3367
  userData: this.queue.current.userData,
3337
3368
  encoded: this.queue.current.encoded
@@ -3381,7 +3412,8 @@ var Player = class {
3381
3412
  this.manager.emit("debug" /* Debug */, 3 /* Player */, `[Player] -> [Stop] Player stopped for guild: ${this.guildId}`);
3382
3413
  this.playing = false;
3383
3414
  this.paused = false;
3384
- this.position = 0;
3415
+ this.lastPosition = 0;
3416
+ this.lastPositionUpdate = null;
3385
3417
  this.queue.current = null;
3386
3418
  return;
3387
3419
  }
@@ -3401,6 +3433,12 @@ var Player = class {
3401
3433
  3 /* Player */,
3402
3434
  `[Player] -> [Pause] Player is now ${paused ? "paused" : "resumed"} for guild: ${this.guildId}`
3403
3435
  );
3436
+ if (paused) {
3437
+ this.lastPositionUpdate = null;
3438
+ } else {
3439
+ this.lastPosition = this.position;
3440
+ this.lastPositionUpdate = Date.now();
3441
+ }
3404
3442
  await this.updatePlayer({ playerOptions: { paused } });
3405
3443
  return paused;
3406
3444
  }
@@ -3568,6 +3606,13 @@ var Player = class {
3568
3606
  selfDeaf: this.selfDeaf,
3569
3607
  options: this.options,
3570
3608
  voice: this.voice,
3609
+ textId: this.textId,
3610
+ lastPosition: this.lastPosition,
3611
+ lastPositionUpdate: this.lastPositionUpdate,
3612
+ position: this.position,
3613
+ createdTimestamp: this.createdTimestamp,
3614
+ ping: this.ping,
3615
+ filters: this.filterManager.toJSON(),
3571
3616
  queue: this.queue.toJSON(),
3572
3617
  node: this.node.toJSON()
3573
3618
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hoshimi",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "A lavalink@v4 client easy to use, up-to-date and all ears.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",