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,22 +1,25 @@
import {inject, injectable} from 'inversify';
import {TYPES} from '../types';
import Player from '../services/player';
import {Client} from 'discord.js';
@injectable()
export default class {
private readonly guildPlayers: Map<string, Player>;
private readonly cacheDir: string;
private readonly discordClient: Client;
constructor(@inject(TYPES.Config.CACHE_DIR) cacheDir: string) {
constructor(@inject(TYPES.Config.CACHE_DIR) cacheDir: string, @inject(TYPES.Client) client: Client) {
this.guildPlayers = new Map();
this.cacheDir = cacheDir;
this.discordClient = client;
}
get(guildId: string): Player {
let player = this.guildPlayers.get(guildId);
if (!player) {
player = new Player(this.cacheDir);
player = new Player(this.cacheDir, this.discordClient);
this.guildPlayers.set(guildId, player);
}