0
votes

I am trying to loop through all of the members in my server and show each of their playing/game messages. This code is in the message event handler:

var members = message.guild.members.map(m => user.presence.game.name);
console.log(members);

When I run this however, I get the following error:

var members = message.guild.members.map(m => user.presence.game.name);
                                                                ^


TypeError: Cannot read property 'name' of null

I cannot figure out how to handle a null playing status, I even tried a filter but that did not work.

Thanks in advance.

1
this probably happens when a player isn't playing any game, you should previously check if user.presence.game isn't nullDavid

1 Answers

0
votes

Can you make the user.presence.game console out with json stringify. Also take a look at array index if is an array try user[0].presence.game.name