Bugfix to stats
This commit is contained in:
parent
f47250c834
commit
092856138c
@ -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);
|
||||
}
|
||||
|
@ -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}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user