Soy nuevo con node.js y javascript y quería codificar un Discord Bot para mi servidor. Estoy trabajando en Embeds y me quedo atascado. Cada vez que quiero ejecutar mi código, esto aparece aquí :
(node:15928) DeprecationWarning: The message event is deprecated. Use messageCreate instead (Use `node --trace-deprecation ...` to show where the warning was created) C:\Users\Lusor\OneDrive\Desktop\dcbot\node_modules\discord.js\src\rest\RequestHandler.js:298 throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: Cannot send an empty message at RequestHandler.execute (C:\Users\Lusor\OneDrive\Desktop\dcbot\node_modules\discord.js\src\rest\RequestHandler.js:298:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (C:\Users\Lusor\OneDrive\Desktop\dcbot\node_modules\discord.js\src\rest\RequestHandler.js:50:14) at async TextChannel.send (C:\Users\Lusor\OneDrive\Desktop\dcbot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:171:15) { method: 'post', path: '/channels/872588467211763804/messages', code: 50006, httpStatus: 400, requestData: { json: { content: undefined, tts: false, nonce: undefined, embeds: undefined, components: undefined, username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: undefined, attachments: undefined, sticker_ids: undefined }, files: [] } }
Y aquí está mi código:
const { Client, Attachment, Message, MessageEmbed } = require("discord.js"); module.exports = { name: "rules", description: "Embeds!", execute(message, args, Discord) { const newEmbed = new MessageEmbed() .setColor('#e38f0e') .setTitle('Rules') .setDescription("Welcome in Valhalla's Game Center! Please read the Rules caredfully!") .addFields( { name: 'Regular field title', value: 'Some value here' }, { name: 'u200B', value: 'u200B' }, { name: 'Inline field title', value: 'Some value here'}, { name: 'Inline field title', value: 'Some value here'}, ) .setImage('https://i.imgur.com/AfFp7pu.png') .setTimestamp() .setFooter('Some footer text here', 'https://i.imgur.com/AfFp7pu.png'); message.channel.send(newEmbed); } }
Literalmente intenté todo y no pude encontrar nada útil.
Encontré la respuesta a su pregunta, incluso si no era lo que estaba causando su problema.
donde tienes
client.on('message', message =>......
cambie el 'message'
a 'messageCreate'
. No tienes que cambiar más mensajes a messageCreate, solo ese. A mí también me estaba molestando.