Answer the question
In order to leave comments, you need to log in
How to find out who invited a user to the discord.js server?
Tried the code:
client.on('guildMemberAdd', member => {
member.guild.fetchInvites().then(guildInvites => {
// This is the *existing* invites for the guild.
const ei = invites[member.guild.id];
// Update the cached invites for the guild.
invites[member.guild.id] = guildInvites;
// Look through the invites, find the one for which the uses went up.
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
// This is just to simplify the message being sent below (inviter doesn't have a tag property)
const inviter = client.users.cache.find(invite.inviter.id);
console.log(inviter.tag)
})
})
Cannot read property 'get' of undefined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question