I made a welcome message but it is not working and gives no errors in the console. All code looks fine to me but it's not working and I don't know why!
welcome.js file code:
module.exports = (client) => {
const channelId = "906885175617683457";
const rulesChannel = "874498102139166731";
client.on("guildMemberAdd", (member) => {
console.log(member);
const message = `Welcome <@${
member.id
}> to our server! Be sure to check out our ${member.guild.channels.cache
.get(rulesChannel)
.toString()}`;
const channel = member.guild.channels.cache.get(channelId);
channel.send(message);
});
};
And index.js file code:
const Discord = require('discord.js');
const client = new Discord.Client();
const welcome = require('./welcome');
client.on ("ready", () => {
console.log("Our bot is online");
welcome(client)
});
client.login(token);
What am I doing wrong?