Jhay
Jhay
DIAdiscord.js - Imagine a boo! 👻
Created by vlad vollar on 8/2/2023 in #djs-questions
Problem with AuditLogs (MessageDelete)
this ensures that the audit log entry corresponds to your own deletion of the message, rather than someone else's deletion.
15 replies
DIAdiscord.js - Imagine a boo! 👻
Created by vlad vollar on 8/2/2023 in #djs-questions
Problem with AuditLogs (MessageDelete)
you can do this is to add an additional check that verifies that the audit log entry was generated by your own deletion of the message
let deleter = null
const auditLogs = await msg.guild.fetchAuditLogs({
type: 72,
limit: 1,
time: {after: msg.createdTimestamp},
target: msg.id
})
const auditLogEntry = auditLogs.entries.first()
if (
auditLogEntry?.target?.id === msg.author.id &&
auditLogEntry?.extra?.channel?.id === msg.channel.id &&
auditLogEntry?.executor?.id === msg.author.id
) {
deleter = auditLogEntry.executor;
}
let deleter = null
const auditLogs = await msg.guild.fetchAuditLogs({
type: 72,
limit: 1,
time: {after: msg.createdTimestamp},
target: msg.id
})
const auditLogEntry = auditLogs.entries.first()
if (
auditLogEntry?.target?.id === msg.author.id &&
auditLogEntry?.extra?.channel?.id === msg.channel.id &&
auditLogEntry?.executor?.id === msg.author.id
) {
deleter = auditLogEntry.executor;
}
i added an additional check that verifies that the executor of the audit log entry (i.e., the user who performed the action that generated the entry) is the same as the author of the message
15 replies
DIAdiscord.js - Imagine a boo! 👻
Created by vlad vollar on 8/2/2023 in #djs-questions
Problem with AuditLogs (MessageDelete)
you need to modify the code to filter out any audit log entries that do not correspond to your own deletion of the message
15 replies
DIAdiscord.js - Imagine a boo! 👻
Created by vlad vollar on 8/2/2023 in #djs-questions
Problem with AuditLogs (MessageDelete)
the code is fetching the latest audit log entry for any message deletions that have occurred after the creation of the message you're checking, regardless of who deleted it so if someone else deletes your message before you delete it yourself, the audit log entry for the other person's deletion will be returned instead of the entry for your own deletion
15 replies
DIAdiscord.js - Imagine a boo! 👻
Created by DriedSponge on 8/3/2023 in #djs-questions
What's the best way of storing an interaction in a Redis instance for a later reply?
no, it is not possible to fetch an instance of an interaction a few minutes later after it has been sent to the bot
7 replies
DIAdiscord.js - Imagine a boo! 👻
Created by DriedSponge on 8/3/2023 in #djs-questions
What's the best way of storing an interaction in a Redis instance for a later reply?
use a library like flatted or json-bigint that supports BigInt serialization
7 replies
DIAdiscord.js - Imagine a boo! 👻
Created by DriedSponge on 8/3/2023 in #djs-questions
What's the best way of storing an interaction in a Redis instance for a later reply?
yes, the problem you're facing happens because BigInt values can't be converted into a JSON string using the JSON.stringify() method, which is what the toJson() method uses to turn the interaction object into a JSON string
7 replies