From fcc8d8881aa338c5011f1173ad2d16efa13591c3 Mon Sep 17 00:00:00 2001 From: MarcoCoreDuo <90222533+MarcoCoreDuo@users.noreply.github.com> Date: Thu, 18 Jul 2024 06:32:16 +0200 Subject: Switch to Distube's ytdl-core fork (resolves playback issue) (#1042) --- src/services/player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/services') diff --git a/src/services/player.ts b/src/services/player.ts index 0da80a4..5e284a6 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -1,7 +1,7 @@ import {VoiceChannel, Snowflake} from 'discord.js'; import {Readable} from 'stream'; import hasha from 'hasha'; -import ytdl, {videoFormat} from 'ytdl-core'; +import ytdl, {videoFormat} from '@distube/ytdl-core'; import {WriteStream} from 'fs-capacitor'; import ffmpeg from 'fluent-ffmpeg'; import shuffle from 'array-shuffle'; @@ -280,8 +280,8 @@ export default class { if (this.getCurrent() && this.status !== STATUS.PAUSED) { await this.play(); } else { - this.audioPlayer?.stop(true); this.status = STATUS.IDLE; + this.audioPlayer?.stop(true); const settings = await getGuildSettings(this.guildId); -- cgit v1.2.3 From 62b1abcba04c776f2a7f8c53478bf4be47011516 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Thu, 18 Jul 2024 00:43:26 -0400 Subject: Switch from node-ytsr to Distube's fork (#1024) Co-authored-by: Max Isom --- src/services/youtube-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/services/youtube-api.ts b/src/services/youtube-api.ts index b7d68b9..143033a 100644 --- a/src/services/youtube-api.ts +++ b/src/services/youtube-api.ts @@ -1,7 +1,7 @@ import {inject, injectable} from 'inversify'; import {toSeconds, parse} from 'iso8601-duration'; import got, {Got} from 'got'; -import ytsr, {Video} from 'ytsr'; +import ytsr, {Video} from '@distube/ytsr'; import PQueue from 'p-queue'; import {SongMetadata, QueuedPlaylist, MediaSource} from './player.js'; import {TYPES} from '../types.js'; -- cgit v1.2.3 From d7261260a3eb6bbe8f5af50dda215ef7b501a8ab Mon Sep 17 00:00:00 2001 From: MintyFreshers Date: Thu, 18 Jul 2024 05:47:01 +0100 Subject: Added skip currently playing track option into the /play options. (#1046) Co-authored-by: Max Isom --- src/services/add-query-to-queue.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/services') diff --git a/src/services/add-query-to-queue.ts b/src/services/add-query-to-queue.ts index 2b84b63..401ad90 100644 --- a/src/services/add-query-to-queue.ts +++ b/src/services/add-query-to-queue.ts @@ -38,12 +38,14 @@ export default class AddQueryToQueue { addToFrontOfQueue, shuffleAdditions, shouldSplitChapters, + skipCurrentTrack, interaction, }: { query: string; addToFrontOfQueue: boolean; shuffleAdditions: boolean; shouldSplitChapters: boolean; + skipCurrentTrack: boolean; interaction: ChatInputCommandInteraction; }): Promise { const guildId = interaction.guild!.id; @@ -169,6 +171,14 @@ export default class AddQueryToQueue { await player.play(); } + if (skipCurrentTrack) { + try { + await player.forward(1); + } catch (_: unknown) { + throw new Error('no song to skip to'); + } + } + // Build response message if (statusMsg !== '') { if (extraMsg === '') { @@ -183,9 +193,9 @@ export default class AddQueryToQueue { } if (newSongs.length === 1) { - await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } else { - await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } } -- cgit v1.2.3