F
F
Flummox_lnc2021-02-07 18:04:20
Node.js
Flummox_lnc, 2021-02-07 18:04:20

How to register the issuance of roles to users using a bot?

In the process of creating the bot, I needed the bot to be able to register the issuance of mut-roles to participants.
The task is as follows:
When issuing a mut-role to a participant, the bot must send a message to a certain channel indicating the user's name and text like "such and such a user received a mut role".
If it's not difficult, tell me how to add an indication of the date and time of issuing the role.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2021-02-15
@KIRIK12

try with this event

client.on('guildMemberUpdate', (oldMember, newMember) => {
  const role = newMember.guild.roles.cache.get('ID роли') || oldMember.guild.roles.cache.get('ID роли')
  if(newMember.roles.cache.has(role) && !oldMember.roles.cache.has(role)) {
    const log = newMember.guild.channels.cache.get('ID канала')
    const updateMess = new Discord.MessageEmbed()
      .setTitle(`Участнику ${newMember} добавлена ${role.name}`)
      .setFooter(newMember.user.avatarURL())
      .setTimestamp()
    log.send(updateMess)
  }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question