move things a bit
This commit is contained in:
parent
2206d68dfb
commit
1f6e6d1098
1 changed files with 8 additions and 14 deletions
|
@ -92,23 +92,17 @@ class Queue<T = unknown> {
|
||||||
const track = options.filtersUpdate ? this.current : src ?? this.tracks.shift();
|
const track = options.filtersUpdate ? this.current : src ?? this.tracks.shift();
|
||||||
if (!track) return;
|
if (!track) return;
|
||||||
|
|
||||||
let resource: AudioResource<Track>;
|
let stream;
|
||||||
|
|
||||||
if (["youtube", "spotify"].includes(track.raw.source)) {
|
if (["youtube", "spotify"].includes(track.raw.source)) {
|
||||||
const stream = ytdl(track.raw.source === "spotify" ? track.raw.engine : track.url, {
|
stream = ytdl(track.raw.source === "spotify" ? track.raw.engine : track.url, {
|
||||||
// because we don't wanna decode opus into pcm again just for volume, let discord.js handle that
|
// because we don't wanna decode opus into pcm again just for volume, let discord.js handle that
|
||||||
opusEncoded: false,
|
opusEncoded: false,
|
||||||
fmt: "s16le",
|
fmt: "s16le",
|
||||||
encoderArgs: options.encoderArgs ?? [],
|
encoderArgs: options.encoderArgs ?? [],
|
||||||
seek: options.seek
|
seek: options.seek
|
||||||
});
|
});
|
||||||
|
|
||||||
resource = this.connection.createStream(stream, {
|
|
||||||
type: StreamType.Raw,
|
|
||||||
data: track
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const stream = ytdl.arbitraryStream(
|
stream = ytdl.arbitraryStream(
|
||||||
track.raw.source === "soundcloud"
|
track.raw.source === "soundcloud"
|
||||||
? await track.raw.engine.downloadProgressive()
|
? await track.raw.engine.downloadProgressive()
|
||||||
: (track.raw.engine as string),
|
: (track.raw.engine as string),
|
||||||
|
@ -120,12 +114,12 @@ class Queue<T = unknown> {
|
||||||
seek: options.seek
|
seek: options.seek
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
resource = this.connection.createStream(stream, {
|
const resource: AudioResource<Track> = this.connection.createStream(stream, {
|
||||||
type: StreamType.Raw,
|
type: StreamType.Raw,
|
||||||
data: track
|
data: track
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const dispatcher = await this.connection.playStream(resource);
|
const dispatcher = await this.connection.playStream(resource);
|
||||||
dispatcher.setVolume(this.options.initialVolume);
|
dispatcher.setVolume(this.options.initialVolume);
|
||||||
|
|
Loading…
Reference in a new issue