0
votes

I've been making a discord bot in Discord.js and I'm trying to make a welcome command. I'm trying to send a message to a specific channel in my server. I don't know how to do this since the update in discord.js because I've done this before. Can you help me?

Here is a chunk of my code:

bot.on('guildMemberAdd', (member) => {
    let embed = new Discord.MessageEmbed()
    .setColor(0xcccccc)
    .setThumbnail(member.user.avatarURL)
    .setTitle("Welcome " + member.user.tag + "!")
    .setDescription("Hello, welcome to this server!")
    .addField("Welcome", "imageurl")
    .setFooter("Server Name")

    bot.channels.find('XXXXX').send(embed)

})
1

1 Answers

0
votes

The introduction of managers is likely the cause of confustion. Try something like this:

// assuming 'bot' is client object in this context
client.channels.fetch( CHANNEL_ID ).then(channel =>{
    channel.send( YOUR_EMBED )
}).catch(err =>{
    // do something with err
})

// if you need to fetch by channel name
let channelsCollection = client.channels.cache; // returns collection
let channel = channelsCollection.find(channel => channel.name === YOUR_CHANNEL_NAME );
channel.send( YOUR_EMBED );