Javascript discord bot 提到用户中句

Thi*_*iil 2 javascript discord.js

试图让机器人吐出随机的场景消息,其中也包含@user 中句。

var myArray = [
  message.author + " challenges the producers, but fails to survive a single puppet",
  "Oh no, " + message.author + " got demolished by **Mr. Smiles**",
  "After gearing up in several events " + message.author + " tried to swim and drowned"
]
var rand = myArray[Math.floor(Math.random() * myArray.length)];
channel.message(rand)
Run Code Online (Sandbox Code Playgroud)

该命令正在链接到此脚本并且到目前为止有效,尽管它没有提及执行命令的用户,而是打印“未定义”。

我对 javascript 还很陌生,但如果您需要更多信息,请告诉我

Tom*_*dos 6

message.author是一个对象。如果您想获得他的名字,请执行以下操作message.author.username 如果您想提及他,请执行以下操作:"<@" + message.author.id + ">"