#New line problem

14 messages · Page 1 of 1 (latest)

muted girder
#
const dinodb = await DinoBreed.findOne({ Dino: dinoFromDb }).lean().exec();
            let historyarray = dinodb.History
            historyarray = historyarray.map(element => element + '\n ');
            if (historyarray.length == 0) {
                const embed = new EmbedBuilder()
                    .setDescription(`${dinoFromDb} não possue histórico.`)
                return interaction.reply({ embeds: [embed] })
            }
            let historyData = JSON.stringify(historyarray)
            historyData = historyData.replace('[', '').replace(/"/g, '').replace(']', '').replace(/,/g, '')
            const embed = new EmbedBuilder()
                .setTitle(`${dinodb.Dino} History`)
                .setDescription(historyData)
            interaction.reply({ embeds: [embed] })```
#

heres my code

frank lichen
#

Use "\n" not '\n'

#

No wait, actually use .join("\n") to make your array into a string, not JSON stringify

final quail
muted girder
#

btw if u dont mind , what would be the difference between using " in \n and '

final quail
#

you don't need the map either btw

final quail
frank lichen
#

Yeah, got confused for a moment…

final quail
#

if you just use join you can avoid the map and replace you have

muted girder
#

thank you