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

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

问题描述

我正在尝试为Discord.js Bot创建一个serverinfo命令。我正在尝试使Discord Server用户计数与服务器的Bot计数分开。有人告诉我使用 .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;

应返回不是行会机器人的成员数量

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

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