2024-09-19 23:58:06 +05:00
|
|
|
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js"),
|
2024-04-30 12:19:44 +05:00
|
|
|
{ QueueRepeatMode } = require("discord-player");
|
2022-08-02 17:18:47 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Loop 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("loop")
|
2022-09-30 23:35:21 +05:00
|
|
|
.setDescription(client.translate("music/loop:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("music/loop:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("music/loop:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-20 20:15:44 +05:00
|
|
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
|
|
|
|
.setContexts([InteractionContextType.Guild])
|
2023-07-05 00:58:06 +05:00
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("option")
|
|
|
|
.setDescription(client.translate("music/loop:OPTION"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("music/loop:OPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("music/loop:OPTION", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true)
|
|
|
|
.setChoices(
|
2024-04-30 12:19:44 +05:00
|
|
|
{ name: client.translate("music/loop:AUTOPLAY"), value: "3" },
|
|
|
|
{ name: client.translate("music/loop:QUEUE"), value: "2" },
|
|
|
|
{ name: client.translate("music/loop:TRACK"), value: "1" },
|
|
|
|
{ name: client.translate("music/loop:DISABLE"), value: "0" },
|
2023-07-05 00:58:06 +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;
|
2022-09-13 22:19:51 +05:00
|
|
|
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true });
|
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", null, { edit: true });
|
2022-08-02 17:18:47 +05:00
|
|
|
|
2023-11-04 16:56:10 +05:00
|
|
|
const translated = {
|
2024-04-30 12:19:44 +05:00
|
|
|
"3": interaction.translate("music/loop:AUTOPLAY_ENABLED"),
|
|
|
|
"2": interaction.translate("music/loop:QUEUE_ENABLED"),
|
|
|
|
"1": interaction.translate("music/loop:TRACK_ENABLED"),
|
|
|
|
"0": interaction.translate("music/loop:LOOP_DISABLED"),
|
2023-11-04 16:56:10 +05:00
|
|
|
};
|
|
|
|
|
2024-04-30 12:19:44 +05:00
|
|
|
const type = interaction.options.getString("option"),
|
|
|
|
mode = type === "3" ? QueueRepeatMode.AUTOPLAY : type === "2" ? QueueRepeatMode.QUEUE : type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF;
|
|
|
|
|
|
|
|
queue.setRepeatMode(mode);
|
|
|
|
|
|
|
|
interaction.reply({ content: translated[type] });
|
2022-08-02 17:18:47 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Loop;
|