繁体   English   中英

Discord.js 错误“消息未定义”

[英]Discord.js error “message is not defined”

**嗨,我正在构建一个新的多功能 discord 机器人,我在控制台启动命令时遇到了一些问题**

  const embed = new Discord.RichEmbed() 
  .setTitle("Este es su título, puede contener 256 caracteres")
  .setAuthor(message.author.username, message.author.avatarURL)
  .setColor(0x00AE86)
  .setDescription("Este es el cuerpo principal del texto, puede contener 2048 caracteres.")
  .setFooter("Pie de página, puede contener 2048 caracteres", client.user.avatarURL)
  .setImage(message.author.avatarURL)
  .setThumbnail(message.author.avatarURL)
  .setTimestamp()
  .setURL("https://github.com/CraterMaik")
  .addField("Este es un título de campo, puede contener 256 caracteres",
    "Este es un valor de campo, puede contener 2048 caracteres.")
  .addField("Campo en línea", "Debajo del campo en línea", true)
  .addBlankField(true)
  .addField("Campo en línea 3", "Puede tener un máximo de 25 campos.", true);
  message.channel.send({embed})}```    





**When i start the comand, i get this error:**

*ReferenceError: message is not defined
    at Object.<anonymous> (C:\Users\leodu\OneDrive\Escritorio\bot2\punch.js:23:1)
  at Module._compile (node:internal/modules/cjs/loader:1109:14)←[39m
  at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)←[39m  
  at Module.load (node:internal/modules/cjs/loader:989:32)←[39m*

Can someone tell me what I can fix in the code?
Thanks.

Firstly, If you are using discord.js V12+ I believe RichEmbed is deprecated and Discord.MessageEmbed() should be used instead (For more about MessagEmbed see the Discord.js docs: https://discord.js.org/#/docs/main/stable /class/MessageEmbed或指南: https://discordjs.guide/popular-topics/embeds.html )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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