Use audit logs. The bot will need permissions though:
client.on("roleDelete", async role => {
let member;
try {
const log = await role.guild.fetchAuditLogs({
type: "ROLE_DELETE"
})
member = role.guild.members.resolve(log.entries.first().executor)
} catch (err) {
console.log(err) // simply for debugging
}
if (!member) member = null
})
And now when you access member
, it will show null
if it couldn't find the executor, but will show the GuildMember
who deleted the role if they were found.
I would recommend you do it through audit logs.
This might help: https://discordjs.guide/popular-topics/audit-logs.html#some-quick-background
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.