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

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-12-16 16:10:16 +01:00
import { TransformPipe } from '@discord-nestjs/common';
2022-12-16 21:21:26 +01:00
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
import { CommandInteraction } from 'discord.js';
import { DiscordMessageService } from '../clients/discord/discord.message.service';
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
import { GenericCustomReply } from '../models/generic-try-handler';
2022-12-16 16:10:16 +01:00
@Command({
name: 'disconnect',
description: 'Join your current voice channel',
})
@UsePipes(TransformPipe)
2022-12-16 21:21:26 +01:00
export class DisconnectCommand implements DiscordCommand {
constructor(
private readonly discordVoiceService: DiscordVoiceService,
private readonly discordMessageService: DiscordMessageService,
) {}
2022-12-16 21:21:26 +01:00
handler(interaction: CommandInteraction): GenericCustomReply {
const disconnect = this.discordVoiceService.disconnect();
2022-12-16 21:21:26 +01:00
if (!disconnect.success) {
return disconnect.reply;
}
2022-12-16 21:21:26 +01:00
return {
embeds: [
this.discordMessageService.buildMessage({
title: 'Disconnected from your channel',
}),
2022-12-16 21:21:26 +01:00
],
};
2022-12-16 16:10:16 +01:00
}
}