Initial Code
This commit is contained in:
40
src/commands/music/loop.ts
Normal file
40
src/commands/music/loop.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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}` });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user