From 1a44065b611000a3e8c877529a2dcc5d2c29a40b Mon Sep 17 00:00:00 2001 From: Miikka Virtanen Date: Wed, 15 Feb 2017 01:14:26 +0200 Subject: [PATCH] Handle error when guild member doesn't have a user --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index be329e3..981e57f 100644 --- a/src/index.js +++ b/src/index.js @@ -131,7 +131,12 @@ Here's what their message contained: console.error(String(err)); }) .then(member => { - const mainGuildNickname = (member != null ? (member.nick || member.username) : 'UNKNOWN'); + let mainGuildNickname = null; + if (member && member.nick) mainGuildNickname = member.nick; + else if (member && member.user) mainGuildNickname = member.user.username; + + if (mainGuildNickname == null) mainGuildNickname = 'UNKNOWN'; + const accountAge = humanizeDuration(Date.now() - msg.author.createdAt, {largest: 2}); const infoHeader = `ACCOUNT AGE **${accountAge}**, ID **${msg.author.id}**, NICKNAME **${mainGuildNickname}**, LOGS **${userLogs.length}**\n-------------------------------`;