问题
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