Updated music

This commit is contained in:
2025-03-02 19:31:14 +01:00
parent 132f88e465
commit 3f3dfdb566
6 changed files with 939 additions and 123 deletions

View File

@@ -5,6 +5,7 @@ import nowplaying from "./music/nowplaying.js"
import pause from "./music/pause.js"
import play from "./music/play.js"
import queue from "./music/queue.js"
import repeat from "./music/repeat.js"
import skip from "./music/skip.js"
import unpause from "./music/unpause.js"
import volume from "./music/volume.js"
@@ -54,6 +55,22 @@ export default {
.setDescription("The amount of songs to skip")
)
)
.addSubcommand(subcommand =>
subcommand
.setName("repeat")
.setDescription("Set repeat mode")
.addStringOption(option =>
option
.setName("mode")
.setDescription("The repeat mode")
.addChoices(
{ name: "Off", value: "off" },
{ name: "Track", value: "track" },
{ name: "Queue", value: "queue" }
)
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName("queue")
@@ -100,6 +117,11 @@ export default {
return
}
if (subcommand === "repeat") {
repeat(interaction)
return
}
if (subcommand === "queue") {
queue(interaction)
return

View File

@@ -19,7 +19,8 @@ const cmd: SubCommand = async (interaction) => {
return
}
// const bitRate = channel.bitrate / 1000
let replyMessage: string = ""
const queue = player.queues.get(interaction.guildId!)
const { track } = await player.play(channel, query, {
requestedBy: interaction.user,
@@ -28,9 +29,15 @@ const cmd: SubCommand = async (interaction) => {
}
})
if (queue) {
replyMessage = `Added [${track.title}](${track.url}) to the queue`
} else {
replyMessage = `Playing [${track.title}](${track.url})`
}
await interaction.editReply({
embeds: [{
description: `Playing [${track.title}](${track.url})`,
description: replyMessage,
thumbnail: {
url: track.thumbnail
},

View File

@@ -0,0 +1,40 @@
import { QueueRepeatMode, useMainPlayer } from "discord-player"
import { embedColor } from "~/config/options.js"
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