Question regarding the behavior of Guild.fetchAuditLogs

Lets say for example I listen to roleCreate event in the client, is it guranteed that the audit log entry for the event exists when I fetch the entries from Guild.fetchAuditLogs after the event was emitted? Example code for better understanding:
client.on("roleCreate", async(role: Role) => {
const auditLogEntry =
(await role.guild.fetchAuditLogs({
type: AuditLogEvent.RoleCreate,
}))
.entries.find((v) => v.targetId == role.id);
// Will auditLogEntry exist or theres a chance the entry hasn't been created yet?
});
client.on("roleCreate", async(role: Role) => {
const auditLogEntry =
(await role.guild.fetchAuditLogs({
type: AuditLogEvent.RoleCreate,
}))
.entries.find((v) => v.targetId == role.id);
// Will auditLogEntry exist or theres a chance the entry hasn't been created yet?
});
Thanks.
3 Replies
d.js toolkit
d.js toolkit6d ago
uh huh
uh huhOP6d ago
I see, alright thank you
d.js toolkit
d.js toolkit6d ago
The thread owner has marked this issue as solved.

Did you find this page helpful?