This is my code and im getting this error: RangeError [EMBED_DESCRIPTION]: MessageEmbed description must be a string can can someone help me please?
const db = require('../models/warns')
const Command = require("../stractures/command");
const Discord = require('discord.js')
module.exports = new Command({
name: "warns",
aliases: [""],
description: "Clear messages",
async run(message, args, client) {
const user = message.mentions.members.first() || message.guild.members.cache.get(args[0])
if (!user) return message.channel.send('User not found.')
const reason = args.slice(1).join(" ")
db.findOne({
guildid: message.guild.id,
user: user.user.id
}, async (err, data) => {
if (err) throw err;
if (data) {
const embed = new Discord.MessageEmbed()
embed.setTitle(`${user.user.tag}'s warns`)
.setDescription(data.content.map((w, i) =>`\`${i + 1}\` | Moderator : ${message.guild.members.cache.get(w.moderator).user.tag}\nReason : ${w.reason}`))
.setColor("BLUE")
message.channel.send({
embeds: [embed]
})
} else {
message.channel.send('User has no data')
}
})
}
})
It’s simply because you are sending an array, rather than a string. Simply joining the array will work
.setDescription(data.content.map((w, i) =>`\`${i + 1}\` | Moderator : ${message.guild.members.cache.get(w.moderator).user.tag}\nReason : ${w.reason}`).join("\n"))