When I run my bot and someone joins, nothing happens.Why nothing happens?
Event file: `const { EmbedBuilder } = require('discord.js')
module.exports = { name: "guildMemberAdd",
/**
* @param {GuildMember} member
*/
execute(member) {
const wcChannel = member.guild.channels.fetch("1155899900161171586")
console.log(`${member.name.toString()}` + "has joined!")
const wcEmbed = new EmbedBuilder()
.setTitle("Welcome")
.setDescription(`${member.name.toString()}` + 'has joined the `SeaMystics`-Server!\n\n**Welcome!**')
.setColor("#4ba511")
.setTimestamp()
wcChannel.send({embeds: [wcEmbed]})
}
}`
Main file: https://haste.l4zs.de/urahanipuv.typescript
Send a message to a channel, when someone joins
Your wcChannel
is a Promise
. You'll need to await it or get the channel from cache [suggested].
const wcChannel = await member.guild.channels.fetch('1155899900161171586');
// ...
wcChannel.send({ embeds: [wcEmbed] });
cache
const wcChannel = member.guild.channels.cache.get('1155899900161171586');
// ...
wcChannel.send({ embeds: [wcEmbed] });
Source: GuildChannelManager