提问者:小点点

无法获取discord.js bot以响应消息内容,只有<@null>


我刚刚从开发和编码/编程的很长一段时间里回来,所以生疏是一个巨大的轻描淡写。

我正在使用discord bot(discord.js)来处理用户填写和发布的某些表单,在收集完这些表单后,应该将其发布在一个单独的隐藏通道上,以便存档,然后删除原始用户发布的信息,将杂乱降到最低。我完全理解,这是一种没有参数和数组的基本工作方式,但对于第一次尝试,它似乎确实几乎如预期的那样工作。

到目前为止,它几乎所有的工作都按预期进行,除了当bot将用户发布的内容发布到存档通道时,它返回“<@null>.”

//Discord, client, and console info up here

client.on('message', message => {
  if (!message.guild) return;
  if (message.content.startsWith('Name:')) {
    message.author.send('Thanks for your interest in the group. Your info will be reviewed shortly')
    message.delete(5000)
  if (message.author.bot) return undefined
  let msg = message.content
  if (message.content.startsWith('Name:')) {
    const generalChannel = message.guild.channels.get('channel-id')
    generalChannel.send(message)
  }
}

//client.login info below here

理想情况下,bot应该能够接收用户发布的内容,并将其与message.author.id一起发布到存档通道中,然后删除用户的原始发布。


共1个答案

匿名用户

更改message.author.send('...')中的引号-当前您正在尝试访问字符串中间的变量n

message.author.send("Thanks for your interest in such'n'such. Your info will be reviewed shortly");

或者转义引号:

message.author.send('Thanks for your interest in such\'n\'such. Your info will be reviewed shortly');