From fa1e41c848021fa17a23a165d3c6d28bb853c56d Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sun, 16 May 2021 20:44:02 -0500 Subject: [PATCH] Fix filter for members --- bot.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bot.js b/bot.js index bfa72c1..dd3f9be 100644 --- a/bot.js +++ b/bot.js @@ -551,9 +551,17 @@ async function userInfo(message) { const members = message.guild.members.cache.filter(member => { if (member.nickname) { - return message.mentions.users.first().id === member.user.id || member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) || member.nickname.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()); + if (message.mentions.users.first()) { + return message.mentions.users.first().id === member.user.id || member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) || member.nickname.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()); + } else { + return member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) || member.nickname.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()); + } } else { - return message.mentions.users.first().id === member.user.id || member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) + if (message.mentions.users.first()) { + return message.mentions.users.first().id === member.user.id || member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) + } else { + return member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()); + } } });