Intenté crear un mensaje incrustado en Discord basado en este discordjs.guide y me encontré con este problema:
RangeError [EMBED_AUTHOR_NAME]: MessageEmbed author name must be a string. at Function.verifyString (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\node_modules\discord.js\src\util\Util.js:413:41) at MessageEmbed.setAuthor (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:356:32) at Object.execute (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\commands\example-embed.js:16:14) at Client.<anonymous> (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\index.js:24:17) at Client.emit (node:events:390:28) at InteractionCreateAction.handle (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:70:12) bsocket\WebSocketShard.js:443:22) at WebSocketShard.onMessage (D:\Kien Thuc\IT\HTML CSS JAVASCRIPT\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10) { [Symbol(code)]: 'EMBED_AUTHOR_NAME' }Aquí está mi código:
const { SlashCommandBuilder } = require('@discordjs/builders'); const { MessageEmbed } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('embeds') .setDescription('embeds'), async execute(interaction) { const exampleEmbed = new MessageEmbed() .setColor('#0099ff') .setTitle('Some title') .setURL('https://discord.js.org/') .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' }) .setDescription('Some description here') .setThumbnail('https://i.imgur.com/AfFp7pu.png') .addFields({ name: 'Regular field title', value: 'Some value here' }, { name: '\u200B', value: '\u200B' }, { name: 'Inline field title', value: 'Some value here', inline: true }, { name: 'Inline field title', value: 'Some value here', inline: true }, ) .addField('Inline field title', 'Some value here', true) .setImage('https://i.imgur.com/AfFp7pu.png') .setTimestamp() .setFooter('Some footer text here', 'https://i.imgur.com/AfFp7pu.png'); await interaction.reply({ embeds: [exampleEmbed] }); }, };Simplemente no entiendo, la clave "nombre" aquí tiene un valor de cadena: 'algún nombre', entonces, ¿por qué no se puede ejecutar? Mi solución temporal aquí es eliminar esa parte del autor y el código funciona sin problemas.
Tuve el mismo problema: lo que me solucionó fue eliminar el {} dentro de .setAuthor() y omitir name: , iconURL: y url: .
Entonces, se vería así:
.setAuthor('Some name','https://i.imgur.com/AfFp7pu.png','https://discord.js.org')