Finished re-working navbar
This commit is contained in:
parent
03fecaddc2
commit
05c1875158
5 changed files with 53 additions and 11 deletions
|
|
@ -28,6 +28,26 @@ const tolerance = 2 * (60 * 1000);
|
|||
//Defaults to five minutes
|
||||
const offlineTimeout = 5 * (60 * 1000);
|
||||
|
||||
module.exports.getOnlineUsers = async function(){
|
||||
//Define array to hold list of online users
|
||||
const users = [];
|
||||
|
||||
//Iterate through all users in the RAM-Backed activity map (only ones that would be online)
|
||||
for(const key of Array.from(activityMap.keys())){
|
||||
//Grab current user, should grab from ram since we're polling activityMap
|
||||
const user = await module.exports.getPresence(key);
|
||||
|
||||
//If the user is online
|
||||
if(user.status == "Streaming" || user.status == "Recently Active"){
|
||||
//Addem' to da list
|
||||
users.push(user);
|
||||
}
|
||||
}
|
||||
|
||||
//Return all found users
|
||||
return users;
|
||||
}
|
||||
|
||||
module.exports.getPresence = async function(user, userDB){
|
||||
//If we don't have a user
|
||||
if(user == null || user == '' || user == 'Tokebot'){
|
||||
|
|
@ -44,7 +64,7 @@ module.exports.getPresence = async function(user, userDB){
|
|||
|
||||
//If we couldn't find anything in RAM
|
||||
if(activity == null){
|
||||
//If we wheren't handed a free user doc
|
||||
//If we wheren't handed a free user doc, and we're allowed to pull from DB
|
||||
if(userDB == null){
|
||||
//Pull one from the username
|
||||
userDB = await userModel.findOne({user: user});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue