Retrieve the author of a voice disconnect

Hello, After a lot of trouble, tests of all kinds, I still can not determine if a user was disconnected by someone, or if he just left by himself. I sometimes come across promising results, but after doing 10 and more tests in all directions, I end up seeing the flaw and detecting a disconnect by someone else when it is a self-deconnection. Do you have any ideas on how to proceed? Thank you in advance
4 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Puparia
PupariaOP4mo ago
try:
let count = 1;



const latestAuditLog = await global.guild.latestAuditLog();
const now = Math.floor(new Date().getTime());

const DT = Math.abs(latestAuditLog.createdTimestamp - now);
console.log(DT, latestAuditLog.extra.count, count);
if (latestAuditLog.action === AuditLogEvent.MemberDisconnect && (DT < 2000 || latestAuditLog.extra.count - count === 1)) {
count = latestAuditLog.extra.count;
console.log('disconnected by another')
return;
}
console.log('self-disconnect')
let count = 1;



const latestAuditLog = await global.guild.latestAuditLog();
const now = Math.floor(new Date().getTime());

const DT = Math.abs(latestAuditLog.createdTimestamp - now);
console.log(DT, latestAuditLog.extra.count, count);
if (latestAuditLog.action === AuditLogEvent.MemberDisconnect && (DT < 2000 || latestAuditLog.extra.count - count === 1)) {
count = latestAuditLog.extra.count;
console.log('disconnected by another')
return;
}
console.log('self-disconnect')
not good
try {

const auditLogs = await newState.guild.fetchAuditLogs({ type: AuditLogEvent.MemberDisconnect });
const firstEntry = auditLogs.entries.first();

if (!firstEntry) return;
if (firstEntry.createdTimestamp >= Date.now() - 2000) {
console.log(
`${newState.member.user.tag} was disconnected from ${oldState.channel.name} by ${firstEntry.executor.tag} (${firstEntry.executor.id})`
);
} else {
`${newState.member.user.tag} self-disconnect`
}
} catch (error) {
console.error('Error when to fetch audits logs', error);
}
try {

const auditLogs = await newState.guild.fetchAuditLogs({ type: AuditLogEvent.MemberDisconnect });
const firstEntry = auditLogs.entries.first();

if (!firstEntry) return;
if (firstEntry.createdTimestamp >= Date.now() - 2000) {
console.log(
`${newState.member.user.tag} was disconnected from ${oldState.channel.name} by ${firstEntry.executor.tag} (${firstEntry.executor.id})`
);
} else {
`${newState.member.user.tag} self-disconnect`
}
} catch (error) {
console.error('Error when to fetch audits logs', error);
}
not good
try {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 27,
});

return fetchedLogs.entries.values().next().value.executorId || null;
} catch (error) {
console.error(`Error fetching audit logs: ${error}`);
return null;
}
try {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 27,
});

return fetchedLogs.entries.values().next().value.executorId || null;
} catch (error) {
console.error(`Error fetching audit logs: ${error}`);
return null;
}
not good Up
duck
duck4mo ago
checking the audit logs is the only means of determining this, and as it sounds like you've seen, it's not necessarily reliable
Puparia
PupariaOP4mo ago
so there is no definitively reliable solution to recover the executor or simply to know if it is disconnected by itself or someone else??? if this is indeed the case, i hope discord will work on it
Want results from more Discord servers?
Add your server