Correctly skip song if unavailable

Also lets user know in text channel that song is unavailable after skipping.

Fixes #324
This commit is contained in:
Max Isom 2021-09-18 16:55:50 -04:00
parent 81bbdb971d
commit 9a2ef876d3
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
6 changed files with 66 additions and 19 deletions

View file

@ -1,5 +1,6 @@
import {TextChannel, Message} from 'discord.js';
import {URL} from 'url';
import {Except} from 'type-fest';
import {TYPES} from '../types';
import {inject, injectable} from 'inversify';
import {QueuedSong, STATUS} from '../services/player';
@ -68,7 +69,7 @@ export default class implements Command {
const addToFrontOfQueue = args[args.length - 1] === 'i' || args[args.length - 1] === 'immediate';
const newSongs: QueuedSong[] = [];
const newSongs: Array<Except<QueuedSong, 'addedInChannelId'>> = [];
let extraMsg = '';
// Test if it's a complete URL
@ -133,7 +134,7 @@ export default class implements Command {
return;
}
newSongs.forEach(song => player.add(song, {immediate: addToFrontOfQueue}));
newSongs.forEach(song => player.add({...song, addedInChannelId: msg.channel.id}, {immediate: addToFrontOfQueue}));
const firstSong = newSongs[0];