【问题标题】:Discord.js/Mongodb Get message author tagDiscord.js/Mongodb 获取消息作者标签
【发布时间】:2020-12-08 07:16:51
【问题描述】:

目前我正在尝试记录使用 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 是必需的,但我不知道它会去哪里。

现在,当有人执行命令时,数据库记录的是机器人和用户的消息,而不是标签

【问题讨论】:

    标签: node.js mongodb discord.js


    【解决方案1】:

    啊哈,我想通了:

    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

    【讨论】:

    • 您可以按问题附近的绿色勾号接受它作为已批准的问题
    • 我知道,但我必须等待 2 天才能做到这一点
    猜你喜欢
    • 2018-03-20
    • 2021-05-12
    • 2016-12-10
    • 2020-11-18
    • 1970-01-01
    • 2021-02-06
    • 1970-01-01
    • 2018-09-01
    • 2021-02-01
    相关资源
    最近更新 更多