Online User count from a Discord Role

前端 未结 2 1976
孤城傲影
孤城傲影 2021-01-28 18:37

I want my Discord Bot to display the Number of Online Users of a Role as an Activity.
I can\'t seem to figure it out and i can\'t find anything on the Web.
Can someone g

2条回答
  •  温柔的废话
    2021-01-28 19:09

    You can use Guild.members.forEach() to loop through every member of the guild, then if they have that role (you can use GuildMember.roles.has(Role.id) to check that) increase a counter. When you have finished your loop through the members, use the counter in your Client.user.setActivity().
    That is what you need in order to get what you want.

    Try this stuff, if you still have problems post a MCVE and we'll help you, but first you need to try yourself.

提交回复
热议问题