0

I found an answer on how to track invites here: How to make a invites command (Discord.js)

    client.on('message', message => {
        if(message.content === "-invite"){
            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.reply(`You have ${userInviteCount} invites.`); 
                }
            )
        }
    });

But what worries me is that this solution could be used for a discord server with 50k members and could check invites every 1-5 seconds. Will the bot still work or will the list be too large or the requests too many? If the list is too large, is there any better method?

76484
  • 8,498
  • 3
  • 19
  • 30
user1324762
  • 765
  • 4
  • 7
  • 24
  • 1
    You're only doing two simple requests, fetching the invites (no matter how much you get it will only count as a single request) and replying to the message) Don't worry about your bot crashing or getting ratelimited unless someones spams the command and you don't have a cooldown system – Staxlinou Oct 21 '21 at 20:38
  • 1
    If I remember correctly, the general rate limit is 10k requests per minute. Unless over a fifth of your 50k member guild uses your invite command at the same time, all within 60 seconds of each other, you won't really have an issue with rate limits. If you're still concerned, implement a cooldown system, where a given user can only use the command once every 5-10 seconds. Then each user can only use the command 6-12 times per minute, eliminating the possibility of even a large group of spammers being able to get you to the rate limit. – Cannicide Oct 21 '21 at 23:12

0 Answers0