-1

Why does this not work? According to the idea, it should output an embed with a greeting and give the role of "traveler" when a new user on server, but something goes wrong, either an error in the embed or in my bad code.

robot.on('guildMemberAdd', member => {
  const userId = member.id;
  const exampleeEmbedd = new MessageEmbed()
  .setColor('#53db56')
  .setTitle('  [] Приветствуем нового путника!')
  .setDescription(' Приветствуем вас <@!'+ userId +'>!\nДобро пожаловать на международный сервер режима Geopolitics. \nЗдесь вы можете присоеденится к существующему городу/государству, либо зарегистрировать свой город/государство.')
  .setURL('')
  .setAuthor('Имперский Бот', 'https://images-ext-2.discordapp.net/external/nWASMV-67mx7guRheeUpvyD_cb6X2NkxUMH4PtbweyA/%3Fsize%3D512/https/cdn.discordapp.com/avatars/916617120064884796/5028d4861b407575072686657b3c2e9a.png' )
  .setThumbnail(member.user.avatarURL())
  .addFields(
  )
  .setImage('')
  .setTimestamp()
  .setFooter('Всего пользователей: ' +  member.guild.memberCount, 'https://images-ext-2.discordapp.net/external/nWASMV-67mx7guRheeUpvyD_cb6X2NkxUMH4PtbweyA/%3Fsize%3D512/https/cdn.discordapp.com/avatars/916617120064884796/5028d4861b407575072686657b3c2e9a.png');
  const role = member.guild.roles.cache.get("921840233883009084")
  member.roles.add(role); 
  var msg = member.guild.channels.get('921833742585188353').
  msg.send( { embeds: [exampleeEmbedd] } ); 
});
MrMythical
  • 8,908
  • 2
  • 17
  • 45
  • 1
    If you are logging anything? It happen? What version are you using? Did you activate intents in developers panel? – Leau Dec 18 '21 at 23:42
  • 1
    Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details which can be done with a [mre]. Please [edit] your question to add these details into it or we may not be able to help. – gre_gor Dec 19 '21 at 00:17
  • Does this answer your question? [None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) – Zsolt Meszaros Dec 19 '21 at 09:44

1 Answers1

1

Your issue most likely lies in that you do not have proper intents for guild member events. In your developer portal under your bot enable the server members intent.

When instantiating your client be sure to add the GUILD_MEMBERS intent in your intents.

Finbar
  • 1,127
  • 1
  • 5
  • 17