简体   繁体   中英

Create a welcome message in the discord bot in js when a new member enters

I am trying to create in my discord bot a "Welcome" message when a new user logs in and for some reason it does not work, there is no error message and the like. Attaching the code, I would really love to help.

  client.on('GulidMemberAdd', (member)  => { console.error("work?")
  let channelId = '814448374790225980'; 
  let embed = new Discord.MessageEmbed()
  .setTitle('member joined!')
  .setDescription('${member.user.tag} join')
  .setTimestamp()
  client.channels.cache.get(channelId).send(embed)
})

There's 2 typos in your code.

client.on('gulidMemberAdd', (member)  => { 
//         ~~~~~ should be guild
  let channelId = '814448374790225980'; 
  let embed = new Discord.MeesageEmbed()
//                        ~~~~~~~ should be Message
  .setTitle('member joined!')
//                ~                       ~ Should be a template literal string
  .setDescription('${member.user.tag} join')
  .setTimestamp()
  client.channels.cache.get(channelId).send(embed)
})

Fixed version:

client.on('guildMemberAdd', (member)  => { 
  let channelId = '814448374790225980'; 
  let embed = new Discord.MessageEmbed()
  .setTitle('member joined!')
  .setDescription(`${member.user.tag} join`)
  .setTimestamp()
  client.channels.cache.get(channelId).send(embed)
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM