Skip to content

Commit

Permalink
Make multiple embeds if queue is too long (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
alhassanv committed Jun 6, 2020
1 parent d502db6 commit 9b10ec0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions commands/queue.js
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
const { MessageEmbed, splitMessage } = require("discord.js");

module.exports = {
name: "queue",
Expand All @@ -7,16 +7,18 @@ module.exports = {
const serverQueue = message.client.queue.get(message.guild.id);

if (!serverQueue) return message.reply("There is nothing playing.").catch(console.error);
const description = serverQueue.songs.map((song, index) => `${index + 1}. ${song.title}`);

let queueEmbed = new MessageEmbed()
.setTitle("EvoBot Music Queue")
.setDescription(serverQueue.songs.map((song, index) => `${index + 1}. ${song.title}`))
.setColor("#F8AA2A");
.setTitle("EvoBot Music Queue")
.setDescription(serverQueue.songs.map((song, index) => `${index + 1}. ${song.title}`))
.setColor("#F8AA2A");

const splitDescription = splitMessage(description, { maxLength: 2048, char: '\n', prepend: '', append: '' });
splitDescription.forEach(async m => {
queueEmbed.setDescription(m);
message.channel.send(queueEmbed);
});

queueEmbed.setTimestamp();
if (queueEmbed.description.length >= 2048)
queueEmbed.description =
queueEmbed.description.substr(0, 2007) + "\nQueue is larger than character limit...";
return message.channel.send(queueEmbed);
}
};

0 comments on commit 9b10ec0

Please sign in to comment.