Skip to content

Bes-js/discord-invite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord

Track the invites in your servers to know who invited who and with which invite!

📂 NPM

📝 Github

Installation

npm i discord-invite

Quick Example

Example For CommonJS

/* Importing The Package */
const InviteManager = require('discord-invite');
const invClient = new InviteManager(client); // client = Discord.Client();

Events

/* Guild Member Join Event */
client.on("memberJoin",async(member,inviter,invite) => { });

/* Guild Member Leave Event */
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); /* <null> */
invClient.inviteRemove(guildId, user); /* <null> */
invClient.getMemberInvites(guildId, user); /* <Object> */
invClient.getGuildInvites(guildId, limit); /* <Array> - limit = min 1 / max 50 / default 10 */

Example Usage;

const InviteManager = require('discord-invite');
const { Client } = require("discord.js");
const invClient = new InviteManager(client); // client = Discord.Client();


/* Join Event */

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}`);
};
});

/* Leave Event */

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

Buy Me A Coffee

Discord Banner