2022-08-03 20:57:54 +05:00
|
|
|
const { SlashCommandBuilder, ActionRowBuilder, SelectMenuBuilder, InteractionCollector, ComponentType } = require("discord.js"),
|
|
|
|
{ QueueRepeatMode } = require("discord-player");
|
2022-08-02 17:18:47 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Loop extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("loop")
|
|
|
|
.setDescription(client.translate("music/loop:DESCRIPTION")),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
|
|
|
guildOnly: true,
|
|
|
|
ownerOnly: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
* @param {Array} data
|
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
const voice = interaction.member.voice.channel;
|
|
|
|
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
|
2022-08-03 20:57:54 +05:00
|
|
|
const queue = client.player.getQueue(interaction.guildId);
|
2022-08-02 17:18:47 +05:00
|
|
|
if (!queue) return interaction.error("music/play:NOT_PLAYING");
|
|
|
|
|
|
|
|
const row = new ActionRowBuilder()
|
|
|
|
.addComponents(
|
|
|
|
new SelectMenuBuilder()
|
2022-08-03 20:57:54 +05:00
|
|
|
.setCustomId("loop_select")
|
2022-08-02 17:18:47 +05:00
|
|
|
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
|
|
|
.addOptions([
|
2022-08-03 20:57:54 +05:00
|
|
|
{
|
|
|
|
label: client.translate("music/loop:AUTOPLAY"),
|
2022-08-06 21:24:01 +05:00
|
|
|
value: 3
|
2022-08-03 20:57:54 +05:00
|
|
|
},
|
2022-08-02 17:18:47 +05:00
|
|
|
{
|
|
|
|
label: client.translate("music/loop:QUEUE"),
|
2022-08-06 21:24:01 +05:00
|
|
|
value: 2
|
2022-08-02 17:18:47 +05:00
|
|
|
},
|
|
|
|
{
|
2022-08-03 20:57:54 +05:00
|
|
|
label: client.translate("music/loop:TRACK"),
|
2022-08-06 21:24:01 +05:00
|
|
|
value: 1
|
2022-08-03 20:57:54 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: client.translate("music/loop:DISABLE"),
|
2022-08-06 21:24:01 +05:00
|
|
|
value: 0
|
2022-08-02 17:18:47 +05:00
|
|
|
}
|
|
|
|
])
|
|
|
|
);
|
|
|
|
|
|
|
|
const msg = await interaction.reply({
|
|
|
|
content: interaction.translate("common:AVAILABLE_CATEGORIES"),
|
|
|
|
components: [row],
|
|
|
|
fetchReply: true
|
|
|
|
});
|
|
|
|
|
|
|
|
const collector = new InteractionCollector(client, {
|
|
|
|
componentType: ComponentType.SelectMenu,
|
|
|
|
message: msg,
|
|
|
|
idle: 60 * 1000
|
|
|
|
});
|
|
|
|
|
2022-08-06 21:11:46 +05:00
|
|
|
collector.on("collect", async i => {
|
2022-08-06 21:24:01 +05:00
|
|
|
const type = i?.values[0];
|
|
|
|
const mode = type === 3 ? QueueRepeatMode.AUTOPLAY :
|
|
|
|
type === 2 ? QueueRepeatMode.QUEUE :
|
|
|
|
type === 1 ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF;
|
|
|
|
|
|
|
|
queue.setRepeatMode(mode);
|
2022-08-06 21:13:50 +05:00
|
|
|
return i.update({
|
2022-08-06 21:24:01 +05:00
|
|
|
content: interaction.translate(`music/loop:${type === 3 ? "AUTOPLAY_ENABLED" :
|
|
|
|
type === 2 ? "QUEUE_ENABLED" : type === 1 ? "TRACK_ENABLED" : "LOOP_DISABLED"}`),
|
2022-08-02 17:18:47 +05:00
|
|
|
components: []
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Loop;
|