All files / src/modules/bot/music/commands NowPlaying.command.ts

0% Statements 0/10
0% Branches 0/2
0% Functions 0/2
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                                                       
import { CommandConfig, CommandPermissions } from "@/common/decorators";
import { CommandConfigGuard, CommandPermissionsGuard } from "@/common/guards";
import { localizationMapByKey } from "@necord/localization";
import { Inject, Logger, UseGuards } from "@nestjs/common";
import { Ctx, SlashCommandContext, Subcommand } from "necord";
import { Music } from "../";
import { MusicCommand } from "../Music.decorator";
import type { IMusicEmbeds, IMusicService } from "../interfaces";
 
@MusicCommand()
export class NowPlayingCommand {
	public constructor(
		@Inject(Music.Embeds) private readonly embeds: IMusicEmbeds,
		@Inject(Music.Service) private readonly service: IMusicService,
	) {}
	private readonly logger = new Logger(NowPlayingCommand.name);
 
	@Subcommand({
		name: "now_playing",
		description: "Shows what song is playing and more information",
		nameLocalizations: localizationMapByKey("Music.nowplaying.name"),
		descriptionLocalizations: localizationMapByKey("Music.nowplaying.description"),
	})
	@CommandConfig({ category: "🎵 Music", disable: false })
	@CommandPermissions({
		bot: ["Connect", "EmbedLinks", "DeafenMembers", "Speak"],
		user: ["Connect", "SendMessages"],
		guildOnly: false,
		ownerOnly: false,
	})
	@UseGuards(CommandConfigGuard, CommandPermissionsGuard)
	public async onCommandRun(@Ctx() [interaction]: SlashCommandContext) {
		if (!(await this.service.checkers(interaction))) {
			return;
		}
 
		const player = await this.service.getPlayer(interaction);
 
		return interaction.reply({
			embeds: [await this.embeds.NowPlaying(interaction, player, await this.service.progressBar(player))],
		});
	}
}