Puparia
Puparia
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
if this is indeed the case, i hope discord will work on it
9 replies
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
so there is no definitively reliable solution to recover the executor or simply to know if it is disconnected by itself or someone else???
9 replies
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
Up
9 replies
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
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
9 replies
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
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
9 replies
DIAdiscord.js - Imagine an app
Created by Puparia on 9/9/2024 in #djs-questions
Retrieve the author of a voice disconnect
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
9 replies