guildinfo: resolve clan game ids

This commit is contained in:
Cynthia Foxwell 2024-08-12 16:06:06 -06:00
parent f0d36959c9
commit 50d36a650f

View file

@ -9,6 +9,7 @@ const {
CDNEndpoints, CDNEndpoints,
ClanPlaystyle, ClanPlaystyle,
ExplicitContentFilterStrings, ExplicitContentFilterStrings,
Games,
Permissions, Permissions,
VerificationLevelStrings, VerificationLevelStrings,
} = require("../../util/dconstants.js"); } = require("../../util/dconstants.js");
@ -76,6 +77,17 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
if (clan) { if (clan) {
const images = []; 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(snowflake), false);
}
return `${game.name} (\`${id}\`)`;
})
);
clanEmbed = { clanEmbed = {
title: _guild != null ? "Clan data" : clan.name, title: _guild != null ? "Clan data" : clan.name,
description: clan.description ?? "*No description*", description: clan.description ?? "*No description*",
@ -106,8 +118,8 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
inline: false, inline: false,
}, },
{ {
name: "Associated Game IDs", name: "Associated Games",
value: `\`${clan.game_ids.map((x) => `"${x}"`).join(", ")}\``, value: `- ${games.join("\n- ")}`,
inline: false, inline: false,
}, },
{ {