2024-09-14 19:52:56 +05:00
|
|
|
const { SlashCommandBuilder, InteractionContextType } = require("discord.js");
|
2022-08-02 17:18:47 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Skip extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-02 17:18:47 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("skip")
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDescription(client.translate("music/skip:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("music/skip:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("music/skip:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
2024-04-29 15:57:02 +05:00
|
|
|
.addIntegerOption(option =>
|
|
|
|
option
|
|
|
|
.setName("position")
|
|
|
|
.setDescription(client.translate("music/skip:POSITION"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("music/skip:POSITION", null, "uk-UA"),
|
|
|
|
ru: client.translate("music/skip:POSITION", null, "ru-RU"),
|
2024-08-13 18:52:55 +05:00
|
|
|
}),
|
2024-04-29 15:57:02 +05:00
|
|
|
),
|
2022-08-02 17:18:47 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-02 17:18:47 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-02 17:18:47 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
const voice = interaction.member.voice.channel;
|
|
|
|
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2024-04-30 12:19:44 +05:00
|
|
|
const queue = client.player.nodes.get(interaction.guildId);
|
|
|
|
if (!queue) return interaction.error("music/play:NOT_PLAYING");
|
2024-04-29 15:57:02 +05:00
|
|
|
|
|
|
|
const position = interaction.options.getInteger("position");
|
|
|
|
|
|
|
|
if (position) {
|
2024-04-30 13:07:22 +05:00
|
|
|
if (position <= 0) return interaction.error("music/skip:NO_PREV_SONG");
|
2024-04-29 15:57:02 +05:00
|
|
|
|
2024-04-30 12:19:44 +05:00
|
|
|
if (queue.tracks.at(position - 1)) {
|
|
|
|
queue.node.skipTo(queue.tracks.at(position - 1));
|
2024-04-29 15:57:02 +05:00
|
|
|
|
2024-04-30 13:07:22 +05:00
|
|
|
interaction.success("music/skip:SUCCESS", {
|
2024-04-30 13:13:03 +05:00
|
|
|
track: `${queue.tracks.at(0).title} - ${queue.tracks.at(0).author}`,
|
2024-04-29 15:57:02 +05:00
|
|
|
});
|
2024-04-30 13:07:22 +05:00
|
|
|
} else return interaction.error("music/skip:ERROR", { position });
|
2024-04-29 15:57:02 +05:00
|
|
|
} else {
|
2024-04-30 12:19:44 +05:00
|
|
|
queue.node.skip();
|
2024-04-30 13:07:22 +05:00
|
|
|
interaction.success("music/skip:SUCCESS", {
|
2024-04-30 13:13:03 +05:00
|
|
|
track: `${queue.tracks.at(0).title} - ${queue.tracks.at(0).author}`,
|
2024-04-30 13:07:22 +05:00
|
|
|
});
|
2024-04-29 15:57:02 +05:00
|
|
|
}
|
2022-08-02 17:18:47 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Skip;
|