magmastream 2.10.2-alpha.7 → 2.10.2-alpha.8
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/structures/Player.js +12 -9
- package/package.json +1 -1
|
@@ -372,7 +372,8 @@ class Player {
|
|
|
372
372
|
if (typeof optionsOrTrack !== "undefined" && Utils_1.TrackUtils.validate(optionsOrTrack)) {
|
|
373
373
|
await this.queue.setCurrent(optionsOrTrack);
|
|
374
374
|
}
|
|
375
|
-
|
|
375
|
+
const currentTrack = await this.queue.getCurrent();
|
|
376
|
+
if (!currentTrack) {
|
|
376
377
|
const error = new MagmastreamError_1.MagmaStreamError({
|
|
377
378
|
code: Enums_1.MagmaStreamErrorCode.PLAYER_QUEUE_EMPTY,
|
|
378
379
|
message: "The queue is empty.",
|
|
@@ -386,7 +387,7 @@ class Player {
|
|
|
386
387
|
guildId: this.guildId,
|
|
387
388
|
data: {
|
|
388
389
|
track: {
|
|
389
|
-
encoded:
|
|
390
|
+
encoded: currentTrack.track,
|
|
390
391
|
},
|
|
391
392
|
...finalOptions,
|
|
392
393
|
position: finalOptions.startTime || 0,
|
|
@@ -683,7 +684,8 @@ class Player {
|
|
|
683
684
|
*/
|
|
684
685
|
async restart() {
|
|
685
686
|
// Check if there is a current track in the queue
|
|
686
|
-
|
|
687
|
+
const currentTrack = await this.queue.getCurrent();
|
|
688
|
+
if (!currentTrack?.track) {
|
|
687
689
|
// If the queue has tracks, play the next one
|
|
688
690
|
if (await this.queue.size())
|
|
689
691
|
await this.play();
|
|
@@ -695,8 +697,8 @@ class Player {
|
|
|
695
697
|
data: {
|
|
696
698
|
position: 0,
|
|
697
699
|
track: {
|
|
698
|
-
encoded:
|
|
699
|
-
userData:
|
|
700
|
+
encoded: currentTrack.track,
|
|
701
|
+
userData: currentTrack.requester,
|
|
700
702
|
},
|
|
701
703
|
},
|
|
702
704
|
});
|
|
@@ -837,7 +839,8 @@ class Player {
|
|
|
837
839
|
* @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
|
|
838
840
|
*/
|
|
839
841
|
async seek(position) {
|
|
840
|
-
|
|
842
|
+
const currentTrack = await this.queue.getCurrent();
|
|
843
|
+
if (!currentTrack)
|
|
841
844
|
return undefined;
|
|
842
845
|
position = Number(position);
|
|
843
846
|
// Check if the position is valid.
|
|
@@ -850,8 +853,8 @@ class Player {
|
|
|
850
853
|
// Get the old player state.
|
|
851
854
|
const oldPlayer = this ? { ...this } : null;
|
|
852
855
|
// Clamp the position to ensure it is within the valid range.
|
|
853
|
-
if (position < 0 || position >
|
|
854
|
-
position = Math.max(Math.min(position,
|
|
856
|
+
if (position < 0 || position > currentTrack.duration) {
|
|
857
|
+
position = Math.max(Math.min(position, currentTrack.duration), 0);
|
|
855
858
|
}
|
|
856
859
|
// Update the player's position.
|
|
857
860
|
this.position = position;
|
|
@@ -925,7 +928,7 @@ class Player {
|
|
|
925
928
|
}
|
|
926
929
|
try {
|
|
927
930
|
const playerPosition = this.position;
|
|
928
|
-
const currentTrack =
|
|
931
|
+
const currentTrack = await this.queue.getCurrent();
|
|
929
932
|
// Safely get voice state properties with null checks
|
|
930
933
|
const sessionId = this.voiceState?.sessionId;
|
|
931
934
|
const token = this.voiceState?.event?.token;
|