Fetching the audit logs not returning as wanted

const kickWithinMinute = await guild.fetchAuditLogs({
type: AuditLogEvent.MemberKick,
after: auditLogEntry.createdTimestamp - 60_000
});
const kickWithinMinute = await guild.fetchAuditLogs({
type: AuditLogEvent.MemberKick,
after: auditLogEntry.createdTimestamp - 60_000
});
What do I need to change to the after: property to only fetch the logs from a minute ago? With this code snippet is returns the MemberKick audit logs that happened way earlier than 1 minute ago of the created audit log entry, like if that after property doesn't exist in the code.
9 Replies
d.js toolkit
d.js toolkit12mo 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! - Marked as resolved by OP
Danial
Danial12mo ago
Why don't you just do Date.now() - 60_000 if you want logs from a minute ago
b3ssel
b3sselOP12mo ago
could do, but why is how I did it fetching all audit logs with kick member so the auditLogEntry.createdTimestamp isn't a snowflake?
Danial
Danial12mo ago
It also takes the auditLogsEntry itself Yeah, true
b3ssel
b3sselOP12mo ago
so I need to convert the timestamp (minus 60 seconds) into a snowflake in order to get it to work Am I still doing something wrong??
const epochTimestamp = auditLogEntry.createdTimestamp - 60_000;
const snowflake = new Snowflake(epochTimestamp).generate();

const kickWithinMinute = await guild.fetchAuditLogs({
type: AuditLogEvent.MemberKick,
after: snowflake
});
const epochTimestamp = auditLogEntry.createdTimestamp - 60_000;
const snowflake = new Snowflake(epochTimestamp).generate();

const kickWithinMinute = await guild.fetchAuditLogs({
type: AuditLogEvent.MemberKick,
after: snowflake
});
followed the docs, told me to do it like this, but still not working
b3ssel
b3sselOP12mo ago
its literally telling me to do it like that
b3ssel
b3sselOP12mo ago
well it directed me to this page tho
No description
b3ssel
b3sselOP12mo ago
that's why I was using it like this but let me try to do it like the SnowFlakeUtil then ah now I know how snowflakes are working, didn't quite understand it well its working now, so thanks a lot for helping me out I just misunderstood the docs a bit
Want results from more Discord servers?
Add your server