2022-12-16 16:10:16 +01:00
|
|
|
import { TransformPipe } from '@discord-nestjs/common';
|
|
|
|
|
2022-12-17 18:31:58 +01:00
|
|
|
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
|
|
|
|
import { CommandInteraction, InteractionReplyOptions } from 'discord.js';
|
|
|
|
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
|
|
|
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
|
2022-12-16 16:10:16 +01:00
|
|
|
|
|
|
|
@Command({
|
|
|
|
name: 'pause',
|
|
|
|
description: 'Pause or resume the playback of the current track',
|
|
|
|
})
|
|
|
|
@UsePipes(TransformPipe)
|
2022-12-17 16:58:38 +01:00
|
|
|
export class PausePlaybackCommand implements DiscordCommand {
|
2022-12-17 18:31:58 +01:00
|
|
|
constructor(
|
|
|
|
private readonly discordVoiceService: DiscordVoiceService,
|
|
|
|
private readonly discordMessageService: DiscordMessageService,
|
|
|
|
) {}
|
|
|
|
|
2022-12-16 16:10:16 +01:00
|
|
|
handler(
|
2022-12-17 18:31:58 +01:00
|
|
|
commandInteraction: CommandInteraction,
|
2022-12-17 16:58:38 +01:00
|
|
|
): string | InteractionReplyOptions {
|
2022-12-18 19:21:33 +01:00
|
|
|
const shouldBePaused = this.discordVoiceService.togglePaused();
|
2022-12-17 18:31:58 +01:00
|
|
|
|
2022-12-17 16:58:38 +01:00
|
|
|
return {
|
2022-12-17 18:31:58 +01:00
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildMessage({
|
2022-12-18 19:21:33 +01:00
|
|
|
title: shouldBePaused ? 'Paused' : 'Unpaused',
|
2022-12-17 18:31:58 +01:00
|
|
|
}),
|
|
|
|
],
|
2022-12-17 16:58:38 +01:00
|
|
|
};
|
2022-12-16 16:10:16 +01:00
|
|
|
}
|
|
|
|
}
|