Discord.js Display Server User Count separately from Server Bot Member Count

佐手、 提交于 2020-04-11 08:09:42

问题


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.


回答1:


Well from guild.members 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.filter(member => !member.user.bot).size;

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



来源:https://stackoverflow.com/questions/49835018/discord-js-display-server-user-count-separately-from-server-bot-member-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!