discord-jellyfin-bot/src/commands/pause.command.ts

33 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-12-16 16:10:16 +01:00
import { TransformPipe } from '@discord-nestjs/common';
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)
export class PausePlaybackCommand implements DiscordCommand {
constructor(
private readonly discordVoiceService: DiscordVoiceService,
private readonly discordMessageService: DiscordMessageService,
) {}
2022-12-16 16:10:16 +01:00
handler(
commandInteraction: CommandInteraction,
): string | InteractionReplyOptions {
2022-12-18 19:21:33 +01:00
const shouldBePaused = this.discordVoiceService.togglePaused();
return {
embeds: [
this.discordMessageService.buildMessage({
2022-12-18 19:21:33 +01:00
title: shouldBePaused ? 'Paused' : 'Unpaused',
}),
],
};
2022-12-16 16:10:16 +01:00
}
}