-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLoop.ts
44 lines (41 loc) · 1.83 KB
/
Loop.ts
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 { QueueRepeatMode, Track } from "discord-player";
import { CommandInteraction, CacheType, MessageEmbed } from "discord.js";
import { Bot } from "../Bot";
import { colorCheck } from "../resources/embedColorCheck";
import { Option, Subcommand } from "./Option";
import { SlashCommand } from "./SlashCommand";
export class Loop implements SlashCommand{
name: string = 'loop';
description: string = 'Loop the song that is currently playing';
options: (Option | Subcommand)[] = [];
requiredPermissions: bigint[] = [];
run(bot: Bot, interaction: CommandInteraction<CacheType>): Promise<void> {
try {
const embed = new MessageEmbed().setColor(colorCheck(interaction.guild!.id));
let queue = bot.player.getQueue(interaction.guild!.id);
if(!queue || !queue.playing) {
embed.setDescription('There is no music playing!');
return interaction.reply({embeds: [embed]});
}
if(queue.repeatMode){
embed.setDescription('Stopped looping');
queue.setRepeatMode(QueueRepeatMode.OFF);
return interaction.reply({embeds: [embed]});
}
queue.setRepeatMode(QueueRepeatMode.TRACK);
embed.setDescription(`Now looping **${queue.nowPlaying().title}** by *${queue.nowPlaying().author}*. Use \`/skip\` to continue the queue`);
return interaction.reply({embeds:[embed]});
}
catch (err) {
bot.logger.commandError(interaction.channel!.id, this.name, err);
return interaction.reply({
content: 'Error: contact a developer to investigate',
ephemeral: true,
});
}
}
guildRequired?: boolean | undefined = true;
managerRequired?: boolean | undefined;
blockSilenced?: boolean | undefined = true;
musicCommand?: boolean | undefined = true;
}