Share your repls and programming experiences

← Back to all posts
How to make a simple invite tracker
NoobieZr (7)

I made this code running on discord.js to track your invites, if you need any help give me a DM on discord here: Tagged#4121.

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

});

Comments
hotnewtop
NoobieZr (7)

This code is broken now with the new d.js update, sorry