我如何查看我的机器人所在的公会中有多少人?

时间:2021-01-24 09:01:25

标签: javascript discord.js

我想看看有多少用户可以与我的机器人交互(比如我的机器人所在的公会中有多少用户)

module.exports.run = async (bot, message, args) => {
    if (!message.member.id === 'myid') return;

    message.channel.send(`Watching ${bot.users.size} users!`);
}
module.exports.config = {
    name: "users",
    aliases: []
  }

我也收到此错误 TypeError: Cannot read property 'size' of undefined 我知道这很愚蠢,但我就是找不到它。提前致谢!

2 个答案:

答案 0 :(得分:0)

如果你使用的是 V12,那么你应该使用这个

bot.users.cache.size

答案 1 :(得分:0)

尝试 message.guild.memberCount 这将返回从哪个公会执行命令的总用户数。