【问题标题】:Embed messages are not displayed in the chat嵌入消息不显示在聊天中
【发布时间】:2020-08-19 09:40:54
【问题描述】:

我尝试使用Discord.js 创建一个机器人。这是我的代码:

import Discord from 'discord.js'
const client = new Discord.Client()

client.once('ready', () => {
  console.log('Ready!')
})

client.login('my-real-token')

client.on('message', message => {
  console.log(message.content)
  if (message.content === '!embed') {
    message.channel.send({
      embed: {
        color: 0x0099ff,
        description: 'A very simple Embed!',
      },
    })
  }
})

但在 Discord 中,它显示为一条空消息:

我尝试使用 the guide 中的两种方式,例如 Discord.MessageEmbed 构造函数和上面代码中的嵌入对象 - 它们看起来都是空的。

channel.send('hello') 之类的简单消息可以正常工作。

我做错了什么?


PS。控制台中没有错误,只是“准备就绪!”和一个“!嵌入”。

PS2。我使用的是打字稿,所以我的构建代码与上面的源代码不同,但我不认为这是一个问题,但我当然可以显示我的 dist 代码。

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    Discord.js 很少使用 embed creator

    通常,这是 Discord.js 使用的。

      if (msg.content === '!embed'){
      const embed = new Discord.RichEmbed()
            .setColor(0x0099ff)
            .setDescription('A very simple Embed!')
      message.channel.send(embed)
    }
    

    【讨论】:

    • 好的,我试过了,得到了这个:TypeError: discord_js_1.default.RichEmbed is not a constructordocumentation 中没有 RichEmbed
    猜你喜欢
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多