Use this command in your terminal to install the package.
cd project-path
npm i --save djs-invite-tracker
const Discord = require("discord.js");
const InviteTracker = require("djs-invite-tracker").default;
const intents = ["GUILDS", "GUILD_INVITES", "GUILD_MEMBERS"];
const partials = ["USER", "GUILD_MEMBER"];
const client = new Discord.Client({
intents,
partials,
});
new InviteTracker(client).init();
client.on("guildMemberAddWithInvite", (member, invite) => {
console.log(member.user.tag);
console.log(invite.code);
});
client.login("token");
You need to do a lot of things to make the invite tracker and get the invite that the user used to join the server. with this package you only need to import the package and call it and it does the job for you.
You can join our discord server to give us suggestions or reports Discord Server.
You can find the source code on Github.