Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Is there any way I can get who gave the role to the log system I'm doing?

I was wanting to make a logging system for roles for my roleplay server but I need to make the bot get the name of who gave the role to that person.

client.on("guildMemberUpdate", (oldMember, newMember) => {
    // Old roles Collection is higher in size than the new one. A role has been removed.
    if (oldMember.roles.cache.size > newMember.roles.cache.size) {
        // Creating an embed message.
        const Embed = new Discord.MessageEmbed();
        Embed.setColor("RED");
        Embed.setAuthor(newMember.user.tag, newMember.user.avatarURL());
        
        // Looping through the role and checking which role was removed.
        oldMember.roles.cache.forEach(role => {
            if (!newMember.roles.cache.has(role.id)) {
                Embed.addField("Role Removed", role);
            }
        });

        client.channels.cache.get("872558074290896908").send(Embed);
    } else if (oldMember.roles.cache.size < newMember.roles.cache.size) {
        const Embed = new Discord.MessageEmbed();
        Embed.setColor("GREEN");
        Embed.setAuthor(newMember.user.tag, newMember.user.avatarURL());
        
        // Looping through the role and checking which role was added.
        newMember.roles.cache.forEach(role => {
            if (!oldMember.roles.cache.has(role.id)) {
                Embed.addField("Role Added", role);
            }
        });
        client.channels.cache.get("872558074290896908").send(Embed);
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For this, you will need to use audit logs as it isn't included in the arguments provided with the event. Working with audit logs can be a bit difficult but the documentation has some great resources like this one to help you get started: https://discordjs.guide/popular-topics/audit-logs.html

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda