我想要一个命令来计算该机器人所在的每个服务器的所有用户。但是,使用我现在拥有的代码,该机器人仅按服务器计数。
if(message.content.startsWith("?membercount")) {
const embed = new Discord.RichEmbed()
.setTitle("**Bot Name**")
.setColor('#0099ff')
.addField('Members', `**${message.guild.memberCount}**`, true)
.addBlankField(true)
.addField('Humans', `**${message.guild.members.filter(member => !member.user.bot).size}**`, true)
.addField('Bots', `**${message.guild.members.filter(member => member.user.bot).size}**`, true)
.addField('Member Status', `**${message.guild.members.filter(o => o.presence.status === 'online').size}** Online\n**${message.guild.members.filter(i => i.presence.status === 'idle').size}** Inactive\n**${message.guild.members.filter(dnd => dnd.presence.status === 'dnd').size}** Do Not Disturb\n**${message.guild.members.filter(off => off.presence.status === 'offline').size}** Offline\n**${message.guild.members.filter(s => s.presence.status === 'streaming').size}** Streaming`)
.setFooter(`© footername`)
message.channel.send({embed});
}
答案 0 :(得分:1)
您可以使用Collection.prototype.reduce()
message.client.guilds.cache.map((g) => g.memberCount).reduce((a, c) => a + c)