T
T
Tima Kochubeev2020-06-01 02:04:32
JavaScript
Tima Kochubeev, 2020-06-01 02:04:32

How can I force the bot to issue a role?

I want to force the bot to give a role to a user for certain achievements (for example, for reaching a certain level), please tell me the structure, or at least tell me how to give a role to a user by his id.

I tried to do something like this, but it doesn't work:

bot.on('guildMemberAdd', (guildMember) => {
  if (levels[user.id].level >= 1) {
  user.id.roles.add(guildMember.guild.roles.cache.find(role => role.name === 'уровень' + ' ' + '1'));
  }
});


discord.js - 12;
node.js 12.17.0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2020-06-01
@notanadm1n

If you don't understand well enough, then you haven't read well enough.

(I read the documentation, and I did not understand very well)

What do you think is happening in this line of code?
user.id.roles.add(guildMember.guild.roles.cache.find(role => role.name === 'уровень' + ' ' + '1'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question