mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Fix music player crash if resource can't be stream
This commit is contained in:
@@ -167,14 +167,20 @@ export class DiscordMusicPlayerInstance {
|
||||
public async playTrack(track: ValidTracks) {
|
||||
|
||||
if (!this.voiceConnection) throw new Error("No voice connection");
|
||||
|
||||
const stream = await playdl.stream(track.url);
|
||||
const resource = createAudioResource(stream.stream, {
|
||||
inputType: stream.type
|
||||
});
|
||||
|
||||
this.player.play(resource)
|
||||
this.voiceConnection.subscribe(this.player)
|
||||
|
||||
try {
|
||||
const stream = await playdl.stream(track.url);
|
||||
const resource = createAudioResource(stream.stream, {
|
||||
inputType: stream.type
|
||||
});
|
||||
|
||||
this.player.play(resource)
|
||||
this.voiceConnection.subscribe(this.player)
|
||||
} catch (error: any) {
|
||||
this.events.emit('error', new PlayerErrorEvent(this, error));
|
||||
this.skipTrack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async skipTrack() {
|
||||
|
||||
Reference in New Issue
Block a user