Track the invites in your servers to know who invited who and with which invite!
Installation
npm i discord-invite
Quick Example
Example For CommonJS
const InviteManager = require('discord-invite');
const invClient = new InviteManager(client);
Events
client.on("memberJoin",async(member,inviter,invite) => { });
client.on("memberLeave",async(member,inviter,invite) => { });
Functions
const InviteManager = require('discord-invite');
const { Client } = require("discord.js");
const invClient = new InviteManager(client);
invClient.inviteAdd(guildId, user);
invClient.inviteRemove(guildId, user);
invClient.getMemberInvites(guildId, user);
invClient.getGuildInvites(guildId, limit);
Example Usage;
const InviteManager = require('discord-invite');
const { Client } = require("discord.js");
const invClient = new InviteManager(client);
client.on("memberJoin", async function(member, inviter, invite) {
if(!inviter) {
console.log(`${member.user.username} joined the server, but I couldn't find out who was invited.`);
} else if(member.id == inviter.id) {
console.log(`${member.user.username} Joined the server by his own invitation!`);
}else if(member.guild.vanityURLCode == inviter) {
console.log(`${member.user.username} Joined Server Using Vanity URL!`);
} else {
invClient.inviteAdd(member.guild.id, inviter);
console.log(`${member.user.tag} Joined the server! inviter ${inviter.username}`);
};
});
client.on("memberLeave",async(member,inviter,invite) => {
if(!inviter) {
console.log(`${member.user.tag} Lefted the server, but I couldn't find out who was invited.`);
} else if(member.id == inviter.id) {
console.log(`${member.user.tag} Lefted the server by his own invitation!`);
} else if(member.guild.vanityURLCode == inviter) {
console.log(`${member.user.tag} Lefted Server Using Vanity URL!`);
} else {
invClient.inviteRemove(member.guild.id, inviter);
console.log(`${member.user.tag} Lefted the server! inviter ${inviter.tag}`);
};
});
client.login("your secret bot token 👻")
discord-invite Also Supports TypeScript And EsModule 🥳!
Credits
Made by FiveSoBes, Relivent And Luppux Development
Contact & Support & Donate