Skip to content
← Back to Community
How to make a setwelcome command that displays the welcome message discord.js
Profile icon
[deleted]

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 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 => c.name === "welcome"); let membercount = guild.members if (!channel) return; let embed = new Discord.MessageEmbed() .setColor("GREEN") .setTitle("New Server Member!") .setDescription(`Welcome, ${member.user.tag} to **${guild.name}!**`) .setThumbnail(member.user.displayAvatarURL()) //.setFooter(`You are the ${membercount}th member to join`); channel.send(embed); });
Voters
Profile icon
NotSwordOP
Profile icon
Perrelos87xbox
Profile icon
facundoaraneda
Profile icon
FABBYG
Profile icon
fex2409
Profile icon
cxchella29
Profile icon
StevanVincent
Profile icon
SamuelClaes
Profile icon
Leroy01010
Comments
hotnewtop
Profile icon
ShuvraBasak

first install the quick.db package by npm i quick.db
then this can be the code for setting up welcome channel:
const Command = require("../Structures/Command.js");
const Discord = require("discord.js");
const { MessageEmbed, MessageActionRow, MessageButton} = require('discord.js');
const db = require('quick.db');

module.exports = new Command({
name: 'setwelcome',
description: 'idk',
permission: 'ADMINISTRATOR',

async run(message, args, client) { const channel = message.mentions.channels.first() if(!channel) return message.channel.send("you need to mention a channel for me to set the welcome channel.") db.set(`welcomechannel_${message.guild.id}`, channel) const embed = new Discord.MessageEmbed() .setTitle('✅ | SUCCESS!') .setDescription(`Welcome channel is now set to ${channel}!`) .setColor('RANDOM') .setFooter(`channel set by ${message.author.username}`) .setTimestamp() message.channel.send({ embeds: [embed]}) }

})

Profile icon
RayRP

Donde pongo el id del canal

Profile icon
FABBYG

Sry But i need .py not .js

Profile icon
JonathanLallaw1
Profile icon
fex2409

everything works! thank you

Profile icon
Benjo989

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

Profile icon
PattanAhmed

@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. :)

Profile icon
Coder100

You would need a database for that.

Profile icon
[deleted]

could I use a .json file? @Coder100

Profile icon
Leroy01010

what language is that

Profile icon
Coder100

node.js :/ @Leroy01010