Discord.js 显示服务器用户计数与服务器机器人成员计数分开 [英] Discord.js Display Server User Count separately from Server Bot Member Count

查看:13
本文介绍了Discord.js 显示服务器用户计数与服务器机器人成员计数分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 Discord.js 机器人创建一个 serverinfo 命令.我正在尝试将 Discord 服务器用户计数与服务器的机器人计数分开.我被告知要使用 .filter 但我不明白如何从用户计数中过滤机器人计数.

I am trying to create a serverinfo command for my Discord.js Bot. I am trying to get the Discord Server User Count separate from the Server's Bot Count. I have been told to use the .filter but I don't understand how to filter the bot count from the user count.

推荐答案

guild.members.cache 你会得到一个包含所有成员(用户和机器人)的集合.使用 .filter 您可以排除"集合中不匹配的项目.例如:

Well from guild.members.cache you'll get a Collection with all the members (users and bots). With .filter you can "exclude" items of a collection if they don't match something. For example:

guild.members.cache.filter(member => !member.user.bot).size;

应该返回 guild 上不是机器人的成员数量.

Should return the number of members that aren't bots on guild.

这篇关于Discord.js 显示服务器用户计数与服务器机器人成员计数分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆