I know this is such a basic question, but 1. I'm new to programing in discord.js (I programmed before in HTML but this is different) 2. I'm very young (I'm a kido LOL)
Ok, so my question is: how do I make a function at my bot that sends a welcome message on a special channel an a DM to the person who joined saying something like "Welcome" ?
I'm asking this cuz I searched on the entire web and I didn't find something that I really understand.
P.S. I would really appreciate if you can add comments with explications.
THANKS IN ADVANCE!
You can use the guildMemberAdd
event to detect when a member joins a guild, ChannelManager#cache
to send a message to a certain channel, and GuildMember#send()
to send a message to a certain member.
<client>.on('guildMemberAdd', (member) => {
// use either `.get('id')` or `.find((c) => c.name === 'name'`
const channel = member.guild.channels.cache.get('Channel ID');
channel.send(...); // send to a channel
member.send(...); // dm the member
});