Bugfix to sameVC inhibitor
Improve some functionality
This commit is contained in:
Erik 2024-03-30 09:42:25 +02:00
parent b8f2aab64f
commit 6a6be77dbd
5 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "navys-music-bot", "name": "navys-music-bot",
"version": "1.1.1", "version": "1.1.2",
"description": "A bot that plays music on discord", "description": "A bot that plays music on discord",
"main": "build/index.js", "main": "build/index.js",
"repository": "https://git.corgi.wtf/Navy.gif/music-bot.git", "repository": "https://git.corgi.wtf/Navy.gif/music-bot.git",

View File

@ -120,6 +120,8 @@ class MusicPlayer implements Initialisable
if (!result) if (!result)
return null; return null;
this.#queue.push(result); this.#queue.push(result);
// Also add to radio playlist
this.#shuffleList.push(result);
return result; return result;
} }

View File

@ -25,6 +25,7 @@ class PingCommand extends Command
{ {
const diff = await this.client.musicPlayer.library.scanLibrary(args.rebuild?.value as boolean); const diff = await this.client.musicPlayer.library.scanLibrary(args.rebuild?.value as boolean);
const songs = this.client.musicPlayer.library.size; const songs = this.client.musicPlayer.library.size;
this.client.musicPlayer.reshuffle();
return `Found ${songs} tracks with ${diff} new ones`; return `Found ${songs} tracks with ${diff} new ones`;
} }
} }

View File

@ -31,8 +31,8 @@ class StatsCommand extends Command
return 'Stats reset'; return 'Stats reset';
} }
const { stats } = this.client.musicPlayer.library; const { stats } = this.client.musicPlayer.library;
const mostPlayed = stats.sort((a, b) => b.plays - a.plays).slice(0, 10); const mostPlayed = stats.sort((a, b) => b.plays - a.plays).filter(entry => entry.plays > 0).slice(0, 10);
const mostSkipped = stats.sort((a, b) => b.skips - a.skips).slice(0, 10); const mostSkipped = stats.sort((a, b) => b.skips - a.skips).filter(entry => entry.skips > 0).slice(0, 10);
let stat = 'plays'; let stat = 'plays';
const mapper = (entry: MusicStatsEntry, pos: number) => const mapper = (entry: MusicStatsEntry, pos: number) =>

View File

@ -19,8 +19,10 @@ class SameVCInhibitor extends Inhibitor
return super._fail('This command cannot be executed outside of a server'); return super._fail('This command cannot be executed outside of a server');
const { me } = guild.members; const { me } = guild.members;
if (!member?.voice || member.voice.channelId !== me?.voice.channelId) if (!me)
super._fail('Only vc participants can queue songs'); return super._fail('What?');
if (!member?.voice || member.voice.channelId !== me.voice.channelId)
return super._fail('Only vc participants can queue songs');
return super._succeed(); return super._succeed();
} }