Bugfix and formatting improvements

This commit is contained in:
Erik 2024-03-29 21:28:13 +02:00
parent 092856138c
commit 18fa150075
4 changed files with 7 additions and 4 deletions

View File

@ -167,7 +167,7 @@ class MusicLibrary implements Initialisable
countSkip (name: string)
{
this.#countStat(name, 'skip');
this.#countStat(name, 'skips');
}
resetStats ()

View File

@ -35,7 +35,7 @@ class QueueCommand extends Command
if (!queue.length)
return 'Queue empty';
return `
**Music queue:**\n${queue.map(entry => `\t\\- **${entry.title}** by ${entry.artist}`).join('\n')}
**Music queue:**\n\`\`\`${queue.map(entry => `\t\\- **${entry.title}** by ${entry.artist}`).join('\n')}\`\`\`
`;
}

View File

@ -36,7 +36,7 @@ class SearchCommand extends Command
if (!results.length)
return 'No results found';
return `
**Search results:**\n${results.map(result => `\t\\- [id: ${result.id}] **${result.title}** - ${result.artist} (Album: ${result.album ?? 'Unknown'}) [${result.year ?? 'Unknown year'}]`).join('\n')}
**Search results:**\n\`\`\`${results.map(result => `\t\\- [id: ${result.id}] **${result.title}** - ${result.artist} (Album: ${result.album ?? 'Unknown'}) [${result.year ?? 'Unknown year'}]`).join('\n')}\`\`\`
`;
}
}

View File

@ -26,7 +26,10 @@ class StatsCommand extends Command
async execute (_message: Message, { args }: CommandOpts)
{
if (args.reset?.value)
{
this.client.musicPlayer.library.resetStats();
return 'Stats reset';
}
const { stats } = this.client.musicPlayer.library;
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);
@ -41,7 +44,7 @@ class StatsCommand extends Command
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}`;
return `**Music statistics**\n\nMost played:\n\`\`\`${top10Plays}\`\`\`\n\nMost skipped:\n\`\`\`${top10Skips}\`\`\``;
}
}