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-17 18:31:58 +01:00
|
|
|
const newStatus = this.discordVoiceService.togglePaused();
|
|
|
|
|
|
|
|
if (newStatus) {
|
|
|
|
return {
|
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildMessage({
|
|
|
|
title: 'Paused',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-17 16:58:38 +01:00
|
|
|
return {
|
2022-12-17 18:31:58 +01:00
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildMessage({
|
|
|
|
title: 'Unpaused',
|
|
|
|
}),
|
|
|
|
],
|
2022-12-17 16:58:38 +01:00
|
|
|
};
|
2022-12-16 16:10:16 +01:00
|
|
|
}
|
|
|
|
}
|