Skip to content

Commit

Permalink
edit embed design for queue command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ballaual committed Apr 5, 2023
1 parent 6af6077 commit f8f652b
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions commands/Music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,41 @@ module.exports = {
.setName("queue")
.setDescription("Displays the current songs in the music queue"),

async execute (interaction) {
const queue = await distube.getQueue(interaction)

if (!queue) {
const queueError = new EmbedBuilder()
.setDescription("There is currently no song in the queue!")
.setColor("#FF0000")

return interaction.reply({ embeds: [queueError], ephemeral: true })
}

const queueItems = queue.songs.map((song, i) => {
return `${i === 0 ? "Playing:" : `${i}.`} ${song.name} - \`${song.formattedDuration}\``
})

const chunkSize = 10 // Number of items to print in each message
const chunkedQueue = []

for (let i = 0; i < queueItems.length; i += chunkSize) {
chunkedQueue.push(queueItems.slice(i, i + chunkSize))
}

for (let i = 0; i < chunkedQueue.length; i++) {
const embed = new EmbedBuilder()
.setDescription(`**Current queue: **\n\n${chunkedQueue[i].join("\n")}`)
.setColor("#FFFF00")

if (i === 0) {
await interaction.reply({ embeds: [embed] })
} else {
await interaction.followUp({ embeds: [embed] })
async execute(interaction) {
const queue = await distube.getQueue(interaction)

if (!queue) {
const queueError = new EmbedBuilder()
.setDescription("There is currently no song in the queue!")
.setColor("#FF0000")

return interaction.reply({ embeds: [queueError], ephemeral: true })
}

const queueItems = queue.songs.map((song, i) => {
return `${i === 0 ? "Playing:" : `${i}.`} ${song.name} - \`${song.formattedDuration}\``
})

const chunkSize = 10 // Number of items to print in each message
const chunkedQueue = []

for (let i = 0; i < queueItems.length; i += chunkSize) {
chunkedQueue.push(queueItems.slice(i, i + chunkSize))
}

for (let i = 0; i < chunkedQueue.length; i++) {
const currentPart = i + 1
const totalParts = chunkedQueue.length
const embed = new EmbedBuilder()
.setTitle(`**Current queue (Part ${currentPart}/${totalParts})**`)
.setDescription(`\n\n${chunkedQueue[i].join("\n")}`)
.setColor("#FFFF00")

if (i === 0) {
await interaction.reply({ embeds: [embed] })
} else {
await interaction.followUp({ embeds: [embed] })
}
}
}
}
}
}

0 comments on commit f8f652b

Please sign in to comment.