diff options
| author | João Costa <[email protected]> | 2024-10-28 16:16:27 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-28 16:16:27 +0000 |
| commit | ce8edf4145469dbaeced2e68c9a138d0fd76d38f (patch) | |
| tree | ae8da28276249570310ef421d80d2d8793bdfb57 /src/services | |
| parent | ae40463712875613c7d485264d61a7965df8a57d (diff) | |
| parent | 534d8fafaa7f09f7ba940d044b08e6c48f800c7a (diff) | |
| download | muse-ce8edf4145469dbaeced2e68c9a138d0fd76d38f.tar.xz muse-ce8edf4145469dbaeced2e68c9a138d0fd76d38f.zip | |
Merge branch 'master' into feature/select-dotenv-path
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/add-query-to-queue.ts | 14 | ||||
| -rw-r--r-- | src/services/player.ts | 4 | ||||
| -rw-r--r-- | src/services/youtube-api.ts | 2 |
3 files changed, 15 insertions, 5 deletions
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<void> { 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}`); } } 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); 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'; |
