guildinfo: sort clan games by activity score

This commit is contained in:
Cynthia Foxwell 2024-08-19 22:23:56 -06:00
parent 51085d8bca
commit 9c2419c796

View file

@ -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 != "");