Discord.JS v13 invite logger module.
$ npm install invite-module
member
-> invited user and returns as server member
invite
-> invite code
inviter
-> inviter and return as user
guild
-> in member guild
const { Discord, Client, Collection, Intents, Guild } = require('discord.js');
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_INVITES] ,
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'ROLE', "GUILD_MEMBER", "USER", "GUILD_INVITES", "MANAGE_GUILD"],
});
//get the module
const invite = require('invite-module');
invite.inviteCounter(client);
guildMemberAdd
, memberJoin
event now.
guildMemberRemove
, memberLeave
event now.
client.on("memberJoin", async(member, invite, inviter, guild) => {
console.log(`${member} joined the server, inviting by: **${inviter.username}**.`);
})
client.on("memberLeave", async(member, invite, inviter, guild) => {
console.log(`${member.user.tag} left the server, was invited by: **${inviter}**.`);
})
Or:
client.on("memberJoin", async(member, invite, inviter, guild) => {
guild.channels.cache.get('channel-id').send(`${member} joined the server, inviting by: **${inviter.username}**.`);
})
client.on("memberLeave", async(member, invite, inviter, guild) => {
guild.channels.cache.get('channel-id').send(`${member.user.tag} left the server, was invited by: **${inviter}**.`);
})
client.on("memberJoin", async(member, invite, inviter, guild) => {
console.log(`Joined ${member}, "${guild}" server, using invite code: ${invite}. Invited by: **${inviter.username}**`);
})
Or
client.on("memberJoin", async(member, invite, inviter, guild) => {
guild.channels.cache.get('channel-id').send(`Joined ${member}, "${guild}" server, using invite code: ${invite}. Invited by: **${inviter.username}**`);
})
Detailed explanation: https://youtu.be/UGWd9BBD6T4