简体   繁体   中英

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty stringss

const Discord = require('discord.js');
exports.run = async(client, message, args) => {

if(!message.member.permissions.has("0x0000000000000008")) return message.channel.send(`> **Bu komutu kullanabilmek için "\`YÖNETİCİt\`" yetkisine sahip olmalısın.**`)

let mesaj = args[0]
if (!mesaj) return message.channel.send('> **Birşey Yazmalısınız**')

await message.delete()

const mesajat = new Discord.EmbedBuilder()
.setColor(Discord.Colors.Blue)
.setDescription(args.slice(0).join(' '))

message.guild.members.cache.map(async user => {
await user.send({ embeds: [mesajat] }).catch(e => {})
})

await message.channel.send(`> **✅ Mesaj basariyla gonderildi.**`)

}

exports.conf = {
aliases: ['duyurlaherkese']
}

exports.help = {
name: 'duyurherkes'
}

I got this error.

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.

Screenshot of the error: Error

And I get this error too:

DeprecationWarning: MessageEmbed#addField is deprecated and will be removed in the next major update. Use MessageEmbed#addFields instead.

Reading the error:

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.

Points us to the EmbedBuilder , specifically the setDescription call. The values can't be '' , null , or undefined . So, on this line:

.setDescription(args.slice(0).join(' '))

You must ensure that args isn't an empty array. Try calling it with a generic string. If it works, then you must figure out why args is empty.

This error message is indicating that the.setDescription(args.slice(0).join(' ')) line is trying to set the description of the embed to an empty string. This is because the args[0] that you are trying to use as the message is not being passed in properly.

The second error message is indicating that the MessageEmbed#addField method is deprecated and will be removed in future versions of discord.js, and you should use MessageEmbed#addFields instead.

You can fix this by making sure that the message passed in as an argument is being passed in properly, and also update the addField method to addFields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM