此刻,我正尝试记录使用mongodb发送消息的用户标签,但我似乎无法全力以赴获取标签本身:
await client.on('message', id => {
Config.findOne({
Author_Tag: id
}, (err, guild) => {
if (err) console.error(err);
if (!guild) {
const newConfig = new Config({
Author_Tag: id,
});
return newConfig.save()
}
})
}
我意识到message.author.id
是必需的,但我不知道它会去哪里。
现在,当有人执行命令时,数据库会记录机器人和用户的消息,而不是标签
答案 0 :(得分:0)
我知道了:
await client.on("message", (message) => {
Config.findOne(
{
Author_Tag: message.author.tag,
},
(err, guild) => {
if (err) console.error(err);
if (!guild) {
const newConfig = new Config({
Author_Tag: message.author.tag,
});
return newConfig.save();
}
}
);
});
我将id
更改为message.author.tag