Files
ChemistryHelpBot/src/commands/music/loop.ts
2025-11-23 13:22:13 -05:00

41 lines
1.5 KiB
TypeScript

import BotCommand from "../../libs/BotCommand";
import BotClient from "../../libs/BotClient";
import { ChatInputCommandInteraction, GuildMember } from "discord.js";
export default class LoopCommand extends BotCommand {
constructor() {
super("loop", "Loop Command", "/loop");
this.data.addStringOption(option =>
option.setName('mode')
.setDescription('Loop mode: off, song, queue')
.setRequired(true)
.addChoices(
{ name: 'Off', value: '0' },
{ name: 'Song', value: '1' },
{ name: 'Queue', value: '2' }
)
);
}
override async execute(Discord: any, client: BotClient, interaction: ChatInputCommandInteraction): Promise<any> {
const member = interaction.member as GuildMember;
if(!member?.voice?.channel) {
return await interaction.reply({ content: "❌ | You need to be in a voice channel!" });
}
const queue = client.distube.getQueue(interaction);
if (!queue) return await interaction.reply({ content: `❌ | There is no music playing!` });
const mode = parseInt(interaction.options.getString('mode')!);
try {
queue.setRepeatMode(mode);
const modeText = mode === 0 ? "Off" : mode === 1 ? "Song" : "Queue";
return await interaction.reply({ content: `🔁 | Loop mode set to: \`${modeText}\`` });
} catch (e) {
return await interaction.reply({ content: `${e}` });
}
}
}