aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/add-query-to-queue.ts14
-rw-r--r--src/services/player.ts4
-rw-r--r--src/services/youtube-api.ts2
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';