2022-09-30 23:35:21 +05:00
|
|
|
const { SlashCommandBuilder } = require("discord.js"),
|
2022-09-13 12:10:32 +05:00
|
|
|
{ QueueRepeatMode } = require("discord-player-play-dl");
|
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")
|
2022-09-30 23:35:21 +05:00
|
|
|
.setDescription(client.translate("music/loop:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-09-30 23:35:21 +05:00
|
|
|
.addStringOption(option => option.setName("option")
|
|
|
|
.setDescription(client.translate("economy/bank:OPTION"))
|
|
|
|
.setRequired(true)
|
|
|
|
.addChoices(
|
|
|
|
{ name: client.translate("music/loop:AUTOPLAY"), value: "3" },
|
|
|
|
{ name: client.translate("music/loop:QUEUE"), value: "2" },
|
|
|
|
{ name: client.translate("music/loop:TRACK"), value: "1" },
|
2022-12-15 21:02:38 +05:00
|
|
|
{ name: client.translate("music/loop:DISABLE"), value: "0" },
|
2022-09-30 23:35:21 +05:00
|
|
|
)),
|
2022-08-02 17:18:47 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-02 17:18:47 +05:00
|
|
|
*/
|
|
|
|
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 });
|
2022-08-03 20:57:54 +05:00
|
|
|
const queue = client.player.getQueue(interaction.guildId);
|
2022-09-13 22:19:51 +05:00
|
|
|
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
|
2022-08-02 17:18:47 +05:00
|
|
|
|
2022-09-30 23:35:21 +05:00
|
|
|
const type = interaction.options.getString("option");
|
|
|
|
const mode = type === "3" ? QueueRepeatMode.AUTOPLAY :
|
|
|
|
type === "2" ? QueueRepeatMode.QUEUE :
|
|
|
|
type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF;
|
2022-08-02 17:18:47 +05:00
|
|
|
|
2022-09-30 23:35:21 +05:00
|
|
|
queue.setRepeatMode(mode);
|
2022-08-02 17:18:47 +05:00
|
|
|
|
2022-09-30 23:35:21 +05:00
|
|
|
interaction.success(`music/loop:${
|
|
|
|
type === "3" ? "AUTOPLAY_ENABLED" :
|
|
|
|
type === "2" ? "QUEUE_ENABLED" :
|
|
|
|
type === "1" ? "TRACK_ENABLED" : "LOOP_DISABLED"
|
|
|
|
}`);
|
2022-08-02 17:18:47 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Loop;
|