A
A
anubis4652020-07-11 15:55:06
JavaScript
anubis465, 2020-07-11 15:55:06

How to correctly display roles in a discord bot?

if(message.content.startsWith(`${prefix}ADM-add`)) {
        message.mentions.members.first().addRole('729044882903007314'); // gets the <GuildMember> from a mention and then adds the role to that member                     
    }

    if(message.content == `${prefix}ADM-list`) {
        const ListEmbed = new Discord.MessageEmbed()
            .setTitle('Users with the ADM role:')
            .setDescription(message.guild.roles.find('729044882903007314').members.map(m=>m.user.tag).join('\n'));
        message.channel.send(ListEmbed);                    
    }
});


Here is my code, when using the command it throws an error:
TypeError: message.guild.roles.find is not a function

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-07-11
@Alexandre888

message.guild.roles.find
use instead
message.guild.roles.cache.find

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question