br1t
br1t
DIAdiscord.js - Imagine an app
Created by br1t on 2/26/2025 in #djs-questions
User leave issue
Hi, I'm making an invite tracking bot for myself, however my leave logic isn't recognising when a user leaves? Originally I thought it may be an SQLite issue, however when adding a debug print statement it doesn't print anything, which is weird because my join logic work and sucesfully prints, could somebody help?
client.on("guildMemberRemove", async member => {
const db = await dbPromise;

const guildInvites = await member.guild.invites.fetch().catch(() => null);
if (!guildInvites) return;

const cachedInvites = invitesCache.get(member.guild.id);
const inviteUsed = guildInvites.find(inv => cachedInvites && cachedInvites.get(inv.code) < inv.uses);

if (!inviteUsed || inviteUsed.code === member.guild.vanityURLCode) return;

const inviterId = inviteUsed.inviter.id;

console.log(`User left after invited from ${inviteUsed.inviter.username} using link ${inviteUsed.code}`);


await db.run("UPDATE invites SET invites = invites - 1 WHERE userId = ?", inviterId);
});

client.on("guildMemberRemove", async member => {
const db = await dbPromise;

const guildInvites = await member.guild.invites.fetch().catch(() => null);
if (!guildInvites) return;

const cachedInvites = invitesCache.get(member.guild.id);
const inviteUsed = guildInvites.find(inv => cachedInvites && cachedInvites.get(inv.code) < inv.uses);

if (!inviteUsed || inviteUsed.code === member.guild.vanityURLCode) return;

const inviterId = inviteUsed.inviter.id;

console.log(`User left after invited from ${inviteUsed.inviter.username} using link ${inviteUsed.code}`);


await db.run("UPDATE invites SET invites = invites - 1 WHERE userId = ?", inviterId);
});

16 replies
DIAdiscord.js - Imagine an app
Created by br1t on 2/8/2025 in #djs-questions
how do i grab the role made by an integration
i need to know how to grab the role id that a bot makes when it joins a discord (e.g the dyno role that dyno makes when it joins)
5 replies
DIAdiscord.js - Imagine an app
Created by br1t on 2/7/2025 in #djs-questions
Issue with Message Logger
No description
9 replies