fix: change map to switch statement

This commit is contained in:
Marius Begby committed 2023-09-14 13:42:58 +02:00
1 parent 2d08a9aa85
commit 7018b690bb
1 file changed
+16 -9
+16 -9
View File
@@ -153,19 +153,26 @@ abstract class BaseInteraction {
} }
protected getDisplayRepeatMode(repeatMode: number): string { protected getDisplayRepeatMode(repeatMode: number): string {
const repeatModesFormatted = new Map([ let loopModeUserString: string;
[0, 'disabled'], let icon: string;
[1, 'track'],
[2, 'queue'],
[3, 'autoplay']
]);
if (repeatMode === 0) { switch (repeatMode) {
case 1:
loopModeUserString = 'track';
icon = this.embedOptions.icons.loop;
break;
case 2:
loopModeUserString = 'queue';
icon = this.embedOptions.icons.loop;
break;
case 3:
loopModeUserString = 'autoplay';
icon = this.embedOptions.icons.autoplay;
break;
default:
return ''; return '';
} }
const loopModeUserString: string = repeatModesFormatted.get(repeatMode)!;
const icon = repeatMode === 3 ? this.embedOptions.icons.autoplay : this.embedOptions.icons.loop;
return ( return (
`**${icon} Looping**\n` + `**${icon} Looping**\n` +
`Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.\n\n` `Loop mode is set to **\`${loopModeUserString}\`**. You can change it with **\`/loop\`**.\n\n`