Answer the question
In order to leave comments, you need to log in
How to fix: TypeError: Cannot read property 'name' of undefined?
I made a bot for a discord, these lines were responsible for issuing a role when a new player entered the server, but something went wrong. An error is thrown: TypeError: Cannot read property 'name' of undefined
Here is the code:
const Discord = module.require("discord.js");
const bot = new Discord.Client();
var newPlayers = [];
var newPlayer = {};
bot.on('guildMemberAdd', (member) =>
{
member.send('Добро пожаловать');
member.addRole(member.roles.some(val => val.name === 'Игрок'));
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question