41 lines
1018 B
TypeScript
41 lines
1018 B
TypeScript
import { QueueRepeatMode, useMainPlayer } from "discord-player"
|
|
import { embedColor } from "~/config/options"
|
|
import { SubCommand } from "~/typings"
|
|
|
|
const QueueRepeatModes = {
|
|
"off": QueueRepeatMode.OFF,
|
|
"track": QueueRepeatMode.TRACK,
|
|
"queue": QueueRepeatMode.QUEUE
|
|
}
|
|
|
|
type RepeatMode = keyof typeof QueueRepeatModes
|
|
|
|
const cmd: SubCommand = async (interaction) => {
|
|
await interaction.deferReply()
|
|
|
|
const mode = interaction.options.getString("mode") as RepeatMode
|
|
const player = useMainPlayer()
|
|
const queue = player.queues.get(interaction.guildId!)
|
|
|
|
if (!queue) {
|
|
await interaction.editReply({
|
|
embeds: [{
|
|
description: "There is no queue",
|
|
color: embedColor
|
|
}]
|
|
})
|
|
return
|
|
}
|
|
|
|
queue.setRepeatMode(QueueRepeatModes[mode])
|
|
|
|
await interaction.editReply({
|
|
embeds: [{
|
|
description: `Repeat mode set to ${mode}`,
|
|
color: embedColor
|
|
}]
|
|
})
|
|
}
|
|
|
|
export default cmd
|