guildinfo: sort clan games by activity score
This commit is contained in:
		
							parent
							
								
									51085d8bca
								
							
						
					
					
						commit
						9c2419c796
					
				
					 1 changed files with 15 additions and 13 deletions
				
			
		| 
						 | 
					@ -78,22 +78,24 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
 | 
				
			||||||
        const images = [];
 | 
					        const images = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const games = await Promise.all(
 | 
					        const games = await Promise.all(
 | 
				
			||||||
          clan.game_ids.map(async (id) => {
 | 
					          clan.game_ids
 | 
				
			||||||
            let game = Games.find((x) => x.id == id);
 | 
					            .sort((a, b) => clan.game_activity[b]?.activity_score ?? 0 - clan.game_activity[a]?.activity_score ?? 0)
 | 
				
			||||||
            if (!game) {
 | 
					            .map(async (id) => {
 | 
				
			||||||
              game = await hf.bot.requestHandler.request("GET", APIEndpoints.APPLICATION_RPC(id), false);
 | 
					              let game = Games.find((x) => x.id == id);
 | 
				
			||||||
            }
 | 
					              if (!game) {
 | 
				
			||||||
 | 
					                game = await hf.bot.requestHandler.request("GET", APIEndpoints.APPLICATION_RPC(id), false);
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let out = `${game.name} (\`${id}\`)`;
 | 
					              let out = `${game.name} (\`${id}\`)`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (clan.game_activity[id]?.activity_level > 1) {
 | 
					              if (clan.game_activity[id]?.activity_level > 1) {
 | 
				
			||||||
              out = `:fire: ${out}`;
 | 
					                out = `:fire: ${out}`;
 | 
				
			||||||
            } else {
 | 
					              } else {
 | 
				
			||||||
              out = `${Icons.blank} ${out}`;
 | 
					                out = `${Icons.blank} ${out}`;
 | 
				
			||||||
            }
 | 
					              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return out;
 | 
					              return out;
 | 
				
			||||||
          })
 | 
					            })
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");
 | 
					        clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue