-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSkip.ts
71 lines (69 loc) · 2.13 KB
/
Skip.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {
ApplicationCommandDataResolvable,
CommandInteraction,
CacheType,
MessageEmbed,
GuildMember,
} from 'discord.js';
import { ApplicationCommandOptionTypes } from 'discord.js/typings/enums';
import { Bot } from '../Bot';
import { SlashCommand } from './SlashCommand';
import { Option } from './Option';
import { colorCheck } from '../resources/embedColorCheck';
import { Queue, QueueRepeatMode } from 'discord-player';
export class Skip implements SlashCommand {
name: string = 'skip';
description = 'Skip the current song in the queue';
options = [
new Option(
'number',
'How many tracks you want to skip in the queue',
ApplicationCommandOptionTypes.INTEGER,
false
)
];
requiredPermissions: bigint[] = [];
async run(
bot: Bot,
interaction: CommandInteraction<CacheType>
): Promise<void> {
try {
const embed = new MessageEmbed().setColor(colorCheck(interaction.guild!.id,true));
let queue = bot.player.getQueue(interaction.guild!.id);
if (!queue || !queue.playing) {
embed.setDescription('There is no music playing!');
return interaction.reply({ embeds: [embed], ephemeral: true });
}
if(queue.repeatMode){
queue.setRepeatMode(QueueRepeatMode.OFF);
}
let tracksToSkip = interaction.options.getInteger('number');
if (tracksToSkip) {
if (tracksToSkip > 15) tracksToSkip = 15;
if (tracksToSkip > queue.tracks.length) {
tracksToSkip = queue.tracks.length;
}
await queue.skipTo(tracksToSkip - 1);
embed.setDescription(
`${tracksToSkip} tracks skipped by ${interaction.user}`
);
return interaction.reply({ embeds: [embed] });
} else {
await queue.skip();
embed.setDescription(`Track skipped by ${interaction.user}`);
return interaction.reply({ embeds: [embed] });
}
} catch (err) {
bot.logger.commandError(interaction.channel!.id, this.name, err);
interaction.reply({
content: 'Error: contact a developer to investigate',
ephemeral: true,
});
return;
}
}
guildRequired?: boolean | undefined = true;
managerRequired?: boolean | undefined;
blockSilenced?: boolean | undefined = true;
musicCommand?: boolean | undefined = true;
}