Discord bot greeting

Hi, my name is Ronald and I am trying to make a discord bot and as many discord bots I want mine to have the function to greet people when they enter my server as a replacement for mee6 to make it more personalized. I am using virtual studio code and I am stuck at one point.

My code is:
const Welcome = require(“discord-welcome”);

const member = client.id

Welcome(client, {

publicmsg : `Goedemorguh ${member}, welkom in **RTA Esport**. Veel plezier in de server :tada: :RTA: !`,

publicchannel : `628313159651819520`

});

and the error I am getting is: member undefined and I want to know how I can fix this. I want my bot to say, goodmorning @member, welcome in RTA Esport, have fun in the server (emotes)

Pls help me :slight_smile:

You dont need to use a package, just use the user joined event

what do you mean? can you maybe show me how you would do it?

You should use a event for this. See this as a example below;

bot.on("guildMemberAdd", member => {
member.guild.channels.get('628313159651819520').send(`Goedemorguh ${member.user}, welkom in **RTA Esport**. Veel plezier in de server :tada: :RTA: !`);
}

By this, the bot sends this message on every member joining on your server. By this it will looks like this:
Goedemorguh SplitXPlayZ#2071, welkom in **RTA Esport**. Veel plezier in de server :tada: :RTA: !.

When I enter the code it will give me the error: bot is not defined so I changed it to client, but now I am getting an error that says: " TypeError: member.guild.channels.get is not a function "

Try this:

bot.on("guildMemberAdd", member =>{
const welcomechannel = bot.channels.cache.get("628313159651819520");
welcomechannel.send(`Goedemorguh ${member}, welkom in **RTA Esport**. Veel plezier in de server :tada: :RTA: !`);
});

For older versions of discord.js, try:

bot.on("guildMemberAdd", member =>{
const welcomechannel = bot.channels.get("628313159651819520");
welcomechannel.send(`Goedemorguh ${member}, welkom in **RTA Esport**. Veel plezier in de server :tada: :RTA: !`);
});

If you are still having issues, please contact me.

1 Like

I’m guessing you’re new to js, I would suggest reading more about js and the djs documentation