K
K
Kirill Bely2020-11-07 22:51:38
Node.js
Kirill Bely, 2020-11-07 22:51:38

How to display the number of invited users?

How to display to the user when requesting for example "!invites" , the number of participants invited by him

For example:
User: !invites
Bot: You invited (number) users to the server!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-11-08
@chupchik_chupachupsa

use the .fetchInvites() method :

var user = null;
user = message.mentions.members.first() || message.author

message.guild.fetchInvites()
  .then

(invites => {
  const userInvites = invites.array().filter(o => o.inviter.id === user.id);
  var userInviteCount = 0;
  for (var i = 0; i < userInvites.length; i++) {
    var invite = userInvites[i];
    userInviteCount += invite.uses;
  }
  message.channel.send(`Вы пригласили ${userInviteCount} пользователей на сервер!`);
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question