Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Why can't I get the nickname of the user who issued / removed the role?

I am trying to find out who has removed / issued a role from the logs, but it does not come out I tried in different ways but it didn't work out, please help.

module.exports = {
    name: 'guildMemberUpdate',
    once: false,
    async execute(oldMember, newMember) {
        try {
            const fetchedLogs = await newMember.guild.fetchAuditLogs({
                limit: 1,
                type: 'MEMBER_UPDATE',
            });
            const memberLog = fetchedLogs.entries.first();
            if (!memberLog) return console.log(`${newMember.displayName} sam`);
            const { executor, target } = memberLog;


            if (oldMember.roles.cache.size < newMember.roles.cache.size) {
                const role = newMember.roles.cache.difference(oldMember.roles.cache).first();
                if (entry.target.id === newMember.user.id) {
                    console.log(`${new Date().toLocaleString('ru-RU', { timeZone: 'Europe/Moscow', hour12: false })} Роль: ${role.name} выдал - ${executor.tag} пользователю - ${newMember.displayName} - <@${newMember.user.id}>`)
                }
                if (oldMember.roles.cache.size > newMember.roles.cache.size) {
                    const role = newMember.roles.cache.difference(oldMember.roles.cache).first();
                    if (entry.target.id === newMember.user.id) {
                        console.log(`${new Date().toLocaleString('ru-RU', { timeZone: 'Europe/Moscow', hour12: false })} Роль: ${role.name} снял - ${executor.tag} пользователю - ${newMember.displayName} - <@${newMember.user.id}>`)
                    }
                }
            }
        } catch (err) {
            return console.log(`Error: ${err.stack}`)
        }
    }
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

GuildAuditLogsEntry.executor is a User instance. To get the GuildMember version with nickname, roles etc. you can look for the user in the GuildMember's guild. This is how you can do it:

newMember.guild.members.resolve(executor)

Keep in mind this relies on cache. Fetching is also an option (it's a promise!):

await newMember.guild.members.fetch(executor.id)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!