-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {ChatInputCommandInteraction} from 'discord.js'; | ||
import {TYPES} from '../types.js'; | ||
import {inject, injectable} from 'inversify'; | ||
import PlayerManager from '../managers/player.js'; | ||
import Command from '.'; | ||
import {SlashCommandBuilder} from '@discordjs/builders'; | ||
import {STATUS} from '../services/player.js'; | ||
|
||
@injectable() | ||
export default class implements Command { | ||
public readonly slashCommand = new SlashCommandBuilder() | ||
.setName('loop-queue') | ||
.setDescription('toggle looping the entire queue'); | ||
|
||
public requiresVC = true; | ||
|
||
private readonly playerManager: PlayerManager; | ||
|
||
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) { | ||
this.playerManager = playerManager; | ||
} | ||
|
||
public async execute(interaction: ChatInputCommandInteraction): Promise<void> { | ||
const player = this.playerManager.get(interaction.guild!.id); | ||
|
||
if (player.status === STATUS.IDLE) { | ||
throw new Error('no songs to loop!'); | ||
} | ||
|
||
if (player.queueSize() < 2) { | ||
throw new Error('not enough songs to loop a queue!'); | ||
} | ||
|
||
if (player.loopCurrentSong) { | ||
player.loopCurrentSong = false; | ||
} | ||
|
||
player.loopCurrentQueue = !player.loopCurrentQueue; | ||
|
||
await interaction.reply((player.loopCurrentQueue ? 'looped queue :)' : 'stopped looping queue :(')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters