mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-29 16:44:58 +05:00
b546036abc
Пакет discord-player на замену distube Фиксики и мелкие правки, как обычно
89 lines
No EOL
2.4 KiB
JavaScript
89 lines
No EOL
2.4 KiB
JavaScript
const { SlashCommandBuilder, ActionRowBuilder, SelectMenuBuilder, InteractionCollector, ComponentType } = require("discord.js"),
|
|
{ QueueRepeatMode } = require("discord-player");
|
|
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");
|
|
const queue = client.player.getQueue(interaction.guildId);
|
|
if (!queue) return interaction.error("music/play:NOT_PLAYING");
|
|
|
|
const row = new ActionRowBuilder()
|
|
.addComponents(
|
|
new SelectMenuBuilder()
|
|
.setCustomId("loop_select")
|
|
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
|
.addOptions([
|
|
{
|
|
label: client.translate("music/loop:AUTOPLAY"),
|
|
value: QueueRepeatMode.AUTOPLAY.toString()
|
|
},
|
|
{
|
|
label: client.translate("music/loop:QUEUE"),
|
|
value: QueueRepeatMode.QUEUE.toString()
|
|
},
|
|
{
|
|
label: client.translate("music/loop:TRACK"),
|
|
value: QueueRepeatMode.TRACK.toString()
|
|
},
|
|
{
|
|
label: client.translate("music/loop:DISABLE"),
|
|
value: QueueRepeatMode.OFF.toString()
|
|
}
|
|
])
|
|
);
|
|
|
|
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
|
|
});
|
|
|
|
collector.on("collect", async msg => {
|
|
const type = Number(msg?.values[0]);
|
|
queue.setRepeatMode(type);
|
|
await msg.update({
|
|
content: interaction.translate(`music/loop:${type === 3 ? "AUTOPLAY_ENABLED" :
|
|
type === 2 ? "QUEUE_ENABLED" : type === 1 ? "TRACK_ENABLED" : "LOOP_DISABLED"}`),
|
|
components: []
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = Loop; |