static user(guild, user, context) {
if (!user) return null;
let users = [];
if (context) {
users = context;
} else {
users = guild.members.fetch();
}
if (!users || !users.length) return null;
let mentionId = new RegExp('<@!?([0-9]+)>', 'g').exec(user);
if (mentionId && mentionId.length > 1) {
return users.find(u => u.id === mentionId[1]);
}
if (user.indexOf('#') > -1) {
let [name, discrim] = user.split('#'),
nameDiscrimSearch = users.find(u => u.username === name && u.discriminator === discrim);
if (nameDiscrimSearch) return nameDiscrimSearch;
}
if (user.match(/^([0-9]+)$/)) {
let userIdSearch = users.find(u => u.id === user);
if (userIdSearch) return userIdSearch;
}
return null;
}