// To compare, we need to load the current invite list.
member.guild.fetchInvites().then(guildInvites => {
// This is the *existing* invites for the guild.
const ei = invites[member.guild.id];
// Update the cached invites for the guild.
invites[member.guild.id] = guildInvites;
// Look through the invites, find the one for which the uses went up.
const invite = guildInvites.cache.find(i => ei.get(i.code).uses < i.uses);
// This is just to simplify the message being sent below (inviter doesn't have a tag property)
const inviter = bot.users.cache.get(invite.inviter.id);
// Get the log channel (change to your liking)
const logChannel = bot.channels.cache.get('718585075171852374');
// A real basic message with the information we need.
logChannel.send(`${member.user.tag} joined using invite code ${invite.code} from ${inviter.tag}. Invite was used ${invite.uses} times since its creation.`);
});
(node:104) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘find’ of undefined
at /home/runner/zfips-bg/index.js:93:39
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v21.4.0 Documentation). (rejection id: 2)