diff --git a/src/client/components/MusicLibrary.ts b/src/client/components/MusicLibrary.ts index 6f7d554..680cb38 100644 --- a/src/client/components/MusicLibrary.ts +++ b/src/client/components/MusicLibrary.ts @@ -188,7 +188,7 @@ class MusicLibrary implements Initialisable } else { - const entry = { ...defaultStats }; + const entry: MusicStatsEntry = { ...defaultStats, name }; (entry[stat] as number)++; this.#stats.set(name, entry); } diff --git a/src/client/components/commands/Stats.ts b/src/client/components/commands/Stats.ts index deb9b53..0f5dd19 100644 --- a/src/client/components/commands/Stats.ts +++ b/src/client/components/commands/Stats.ts @@ -31,13 +31,15 @@ class StatsCommand extends Command const mostPlayed = stats.sort((a, b) => b.plays - a.plays).slice(0, 10); const mostSkipped = stats.sort((a, b) => b.skips - a.skips).slice(0, 10); + let stat = 'plays'; const mapper = (entry: MusicStatsEntry, pos: number) => { pos++; const [ idx ] = this.client.musicPlayer.library.search({ title: entry.name }); - return `\t[${('00' + pos).slice(-2)}] **${idx.title}** by ${idx.artist}`; + return `\t[${('00' + pos).slice(-2)}]\t**${idx.title}** by ${idx.artist} (${entry[stat]})`; }; const top10Plays = mostPlayed.map(mapper).join('\n'); + stat = 'skips'; const top10Skips = mostSkipped.map(mapper).join('\n'); return `**Music statistics**\n\nMost played:\n${top10Plays}\n\nMost skipped:\n${top10Skips}`; }