I am trying to make a welcoming message to whoever joins my discord server with this bot, but nothing happens when someone joins. I am getting an error: ReferenceError: channelname is not defined at C:\Users\Vir\Desktop\DiscBot\index.js:13:71 at Map.find (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\util\Collection.js:506:11) at Client. (C:\Users\Vir\Desktop\DiscBot\index.js:13:43) at Client.emit (events.js:223:5) at Guild._addMember (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\structures\Guild.js:1298:19) at GuildMemberAddHandler.handle (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\client\websocket\packets\handlers\GuildMemberAdd.js:12:13) at WebSocketPacketManager.handle (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65) at WebSocketConnection.onPacket (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (C:\Users\Vir\Desktop\DiscBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17) at WebSocket.onMessage (C:\Users\Vir\Desktop\DiscBot\node_modules\ws\lib\event-target.js:120:16) PS C:\Users\Vir\Desktop\DiscBot> But I have no clue what that means. I've tried searching it up and found nothing. The code is
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = "NzEzMTcwNjc4NjYwMjAyNTA2.XscOxQ.0YxwpbBEITN0DIwGFwYIdRxCOu0";
const PREFIX = ";";
bot.on('ready', () =>{
console.log('This bot is online!');
})
bot.on('guildMemberAdd', member =>{
const channel = member.guild.channels.find(channel => channelname === "welcome");
if(!channel) return;
channel.send('Welcome, ${member}, make sure to read the rules and verfiy.')
});
bot.on('message', message=>{
let args = message.content.substring(PREFIX.length).split(" ")
switch(args[0]){
case 'Version':
message.reply('Version 1.0.0');
break;
case 'Commands':
message.reply(';Version ;Commands');
break;
}
})
bot.login(token);