Ask coding questions

← Back to all posts
How to make a setwelcome command that displays the welcome message discord.js

Hi there! I am currently making a discord.js v12 bot, and I have a welcome message command in the bot. As of now, the code just finds a channel name of welcome, and puts the message there. I want to change that to where a user can run a .setwelcome <channel> command, and it will then display the welcome message there. How could I do this?

(Here is my current code):

client.on('guildMemberAdd', member => {
  if (!member.guild) return;
  let guild = member.guild
  let channel = guild.channels.cache.find(c => === "welcome");

  let membercount = guild.members
  if (!channel) return;
  let embed = new Discord.MessageEmbed() 
    .setTitle("New Server Member!")
    .setDescription(`Welcome, ${member.user.tag} to **${}!**`)
    //.setFooter(`You are the ${membercount}th member to join`);
fex2409 (0)

everything works! thank you

Benjo989 (2)

@fex2409 i saw your latest repl, you copied this code and there's alot of errors...

PattanAhmed (1411)

@JollyJack8 Hi,
I think you would probably need a database to complete what you think, I guess!

Hope this helps
Please mark my answer if this helps. :)

Coder100 (18873)

You would need a database for that.


could I use a .json file? @Coder100