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 games = await Promise.all(
clan.game_ids.map(async (id) => {
let game = Games.find((x) => x.id == id);
if (!game) {
game = await hf.bot.requestHandler.request("GET", APIEndpoints.APPLICATION_RPC(id), false);
}
clan.game_ids
.sort((a, b) => clan.game_activity[b]?.activity_score ?? 0 - clan.game_activity[a]?.activity_score ?? 0)
.map(async (id) => {
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) {
out = `:fire: ${out}`;
} else {
out = `${Icons.blank} ${out}`;
}
if (clan.game_activity[id]?.activity_level > 1) {
out = `:fire: ${out}`;
} else {
out = `${Icons.blank} ${out}`;
}
return out;
})
return out;
})
);
clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");