Confused About Discord Invites: Are They Always Linked to the Original Creator?

I’m trying to understand how Discord invite links work ? Specifically: - Is each generated invite code always linked to the user who originally created it? - Does users can generate the same link ? - Can a code be shared around by multiple people, and does Discord still store the first user who made it? For example in this snippet, why does the code look for uses differences
client.on("guildMemberAdd", async (member) => {
// To compare, we need to load the current invite list.
const newInvites = await member.guild.invites.fetch()
// This is the *existing* invites for the guild.
const oldInvites = invites.get(member.guild.id);
// Look through the invites, find the one for which the uses went up.
const invite = newInvites.find(i => i.uses > oldInvites.get(i.code));
// This is just to simplify the message being sent below (inviter doesn't have a tag property)
const inviter = await client.users.fetch(invite.inviter.id);
// Get the log channel (change to your liking)
const logChannel = member.guild.channels.cache.find(channel => channel.name === "join-logs");
// A real basic message with the information we need.
inviter
? logChannel.send(`${member.user.tag} joined using invite code ${invite.code} from ${inviter.tag}. Invite was used ${invite.uses} times since its creation.`)
: logChannel.send(`${member.user.tag} joined but I couldn't find through which invite.`);
});
client.on("guildMemberAdd", async (member) => {
// To compare, we need to load the current invite list.
const newInvites = await member.guild.invites.fetch()
// This is the *existing* invites for the guild.
const oldInvites = invites.get(member.guild.id);
// Look through the invites, find the one for which the uses went up.
const invite = newInvites.find(i => i.uses > oldInvites.get(i.code));
// This is just to simplify the message being sent below (inviter doesn't have a tag property)
const inviter = await client.users.fetch(invite.inviter.id);
// Get the log channel (change to your liking)
const logChannel = member.guild.channels.cache.find(channel => channel.name === "join-logs");
// A real basic message with the information we need.
inviter
? logChannel.send(`${member.user.tag} joined using invite code ${invite.code} from ${inviter.tag}. Invite was used ${invite.uses} times since its creation.`)
: logChannel.send(`${member.user.tag} joined but I couldn't find through which invite.`);
});
Tracking Used Invited
4 Replies
d.js toolkit
d.js toolkit2d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Lev
LevOP2d ago
I think I get it https://discord.com/channels/222078108977594368/824411059443204127/1234073444702879854 This message help me to understand a bit more about how works invite ahah It's simple but yeah... The key part of making an invite tracker is to keep count of 'uses'
d.js docs
d.js docs2d ago
Discord does not provide the invite that a member used to join through the bot API. - Tracking the uses of invites through the inviteCreate and guildMemberAdd events is unreliable and we recommend against it. - Discord has not shared any plans to make the members tab available for bots.
Tomsoz
Tomsoz2d ago
yeah the user stored along with the invite never changes, it's the user that created the invite

Did you find this page helpful?