I want to change this part into a code block message
message.channel.send(`${client.player.getQueue(message).loopMode ? '(looped)' : ''}nCurrent: **__${queue.playing.author} | ${queue.playing.title}__** nn` + (queue.tracks.map((track, i) => { return `**${i + 1})** ${track.author} - ${track.title} | ${track.requestedBy.username}` }).slice(0, 10).join('n') + `nn${queue.tracks.length > 10 ? `And **${queue.tracks.length - 10}** more track(s)` : ` **This is the end of the queue!**`}`));
I tried but it’s not working
Here’s the full code
module.exports = { name: 'queue', aliases: ['q'], category: 'Music', utilisation: '{prefix}queue', execute(client, message) { const queue = client.player.getQueue(message); message.channel.send(`${client.player.getQueue(message).loopMode ? '(looped)' : ''}nCurrent: **__${queue.playing.author} | ${queue.playing.title}__** nn` + (queue.tracks.map((track, i) => { return `**${i + 1})** ${track.author} - ${track.title} | ${track.requestedBy.username}` }).slice(0, 10).join('n') + `nn${queue.tracks.length > 10 ? `And **${queue.tracks.length - 10}** more track(s)` : ` **This is the end of the queue!**`}`)); }, };
Advertisement
Answer
Since codeblocks have to be made with tripple `, you can just add them to the beginning and end like you normally do but escape them with a backslash so your normal string template doesnt end early:
message.channel.send(````${client.player.getQueue(message).loopMode ? '(looped)' : ''}nCurrent: **__${queue.playing.author} | ${queue.playing.title}__** nn` + (queue.tracks.map((track, i) => { return `**${i + 1})** ${track.author} - ${track.title} | ${track.requestedBy.username}` }).slice(0, 10).join('n') + `nn${queue.tracks.length > 10 ? `And **${queue.tracks.length - 10}** more track(s)` : ` **This is the end of the queue!**`}````));