lookupinvite: copypaste updated profile support
This commit is contained in:
parent
34d778fe13
commit
3e373fb91b
1 changed files with 53 additions and 79 deletions
|
@ -218,123 +218,97 @@ lookupinvite.callback = async function (msg, line) {
|
||||||
return `Unhandled invite type: \`${invite.type}\``;
|
return `Unhandled invite type: \`${invite.type}\``;
|
||||||
}
|
}
|
||||||
|
|
||||||
const clan = invite.profile;
|
const profile = invite.profile;
|
||||||
let clanEmbed;
|
let clanEmbed;
|
||||||
if (clan) {
|
if (profile) {
|
||||||
const images = [];
|
const images = [];
|
||||||
|
|
||||||
const game_ids = clan.game_ids ?? clan.game_application_ids ?? [];
|
const game_ids = profile.game_ids ?? profile.game_application_ids ?? [];
|
||||||
const games = await Promise.all(
|
const games = await Promise.all(
|
||||||
game_ids
|
game_ids
|
||||||
.sort((a, b) => (clan.game_activity[b]?.activity_score ?? 0) - (clan.game_activity[a]?.activity_score ?? 0))
|
.sort(
|
||||||
|
(a, b) => (profile.game_activity[b]?.activity_score ?? 0) - (profile.game_activity[a]?.activity_score ?? 0)
|
||||||
|
)
|
||||||
.map(async (id) => {
|
.map(async (id) => {
|
||||||
let game = Games.find((x) => x.id == id);
|
let game = Games.find((x) => x.id == id);
|
||||||
if (!game) {
|
if (!game) {
|
||||||
game = await hf.bot.requestHandler.request("GET", APIEndpoints.APPLICATION_RPC(id), false);
|
game = await hf.bot.requestHandler.request("GET", APIEndpoints.APPLICATION_RPC(id), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let out = `${game.name} (\`${id}\`)`;
|
return `${game.name}${
|
||||||
|
profile.game_activity[id]?.activity_level > 1 ? " \ud83d\udd25" : ""
|
||||||
if (clan.game_activity[id]?.activity_level > 1) {
|
}\n-# \u200b\u3000${id}`;
|
||||||
out = `:fire: ${out}`;
|
|
||||||
} else {
|
|
||||||
out = `${Icons.blank} ${out}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (clan.wildcard_descriptors) clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");
|
if (profile.wildcard_descriptors)
|
||||||
|
profile.wildcard_descriptors = profile.wildcard_descriptors.filter((x) => x != "");
|
||||||
|
|
||||||
const termLines = [];
|
let traits = "";
|
||||||
let currentTerm = "";
|
if (profile.search_terms) {
|
||||||
if (clan.search_terms) {
|
traits = profile.search_terms.map((term) => `[\u2005${term}\u2005]`).join(" ");
|
||||||
for (const index in clan.search_terms) {
|
} else if (profile.traits) {
|
||||||
const term = clan.search_terms[index];
|
traits = profile.traits
|
||||||
const formattedTerm = `\`\u2004${term.replaceAll(" ", "\u2005")}\u2004\``;
|
.map((term) => `[\u2005${term.emoji_name ? `:${term.emoji_name}: ` : ""}${term.label}\u2005]`)
|
||||||
if (currentTerm.length + 1 + formattedTerm.length > 56) {
|
.join(" ");
|
||||||
termLines.push(currentTerm);
|
|
||||||
currentTerm = formattedTerm;
|
|
||||||
} else {
|
|
||||||
currentTerm += "\u2004" + formattedTerm;
|
|
||||||
}
|
|
||||||
if (index == clan.search_terms.length - 1) termLines.push(currentTerm);
|
|
||||||
}
|
|
||||||
} else if (clan.traits) {
|
|
||||||
for (const index in clan.traits) {
|
|
||||||
const term = clan.traits[index];
|
|
||||||
const formattedTerm = `${term.emoji_name ? `:${term.emoji_name}:` : ""}\`\u2004${term.label.replaceAll(
|
|
||||||
" ",
|
|
||||||
"\u2005"
|
|
||||||
)}\u2004\``;
|
|
||||||
if (currentTerm.length + 1 + formattedTerm.length > 56) {
|
|
||||||
termLines.push(currentTerm);
|
|
||||||
currentTerm = formattedTerm;
|
|
||||||
} else {
|
|
||||||
currentTerm += "\u2004" + formattedTerm;
|
|
||||||
}
|
|
||||||
if (index == clan.traits.length - 1) termLines.push(currentTerm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let gameLines = "";
|
|
||||||
let gameLines2 = "";
|
|
||||||
for (const line of games) {
|
|
||||||
if (gameLines.length + line.length + 1 <= 1024) {
|
|
||||||
gameLines += line + "\n";
|
|
||||||
} else {
|
|
||||||
gameLines2 += line + "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gamesLeft = games.slice(0, Math.ceil(games.length / 2)).join("\n");
|
||||||
|
const gamesRight = games.slice(Math.ceil(games.length / 2), games.length).join("\n");
|
||||||
clanEmbed = {
|
clanEmbed = {
|
||||||
color: clan.brand_color_primary ? parseInt(clan.brand_color_primary.replace("#", "0x")) : 0,
|
color: profile.brand_color_primary ? parseInt(profile.brand_color_primary.replace("#", "0x")) : 0,
|
||||||
author: {
|
author: {
|
||||||
name: clan.tag,
|
name: profile.tag,
|
||||||
},
|
},
|
||||||
description:
|
description:
|
||||||
clan.playstyle || clan.wildcard_descriptors
|
profile.playstyle || profile.wildcard_descriptors
|
||||||
? `-# :video_game:${ClanPlaystyle[clan.playstyle] ?? "Unknown"}${
|
? `-# :video_game:${ClanPlaystyle[profile.playstyle] ?? "Unknown"}${
|
||||||
clan.wildcard_descriptors.length > 0 ? ` \u2022 **${clan.wildcard_descriptors.join(", ")}**` : ""
|
profile.wildcard_descriptors.length > 0 ? ` \u2022 **${profile.wildcard_descriptors.join(", ")}**` : ""
|
||||||
}\n\n${clan.description ?? "*No description*"}`
|
}\n\n${profile.description ?? "*No description*"}`
|
||||||
: clan.description ?? "*No description*",
|
: profile.description ?? "*No description*",
|
||||||
fields: [
|
fields: [
|
||||||
termLines.length > 0 && {
|
traits != "" && {
|
||||||
name: "Traits",
|
name: "Traits",
|
||||||
value: termLines.join("\n"),
|
value: traits,
|
||||||
inline: false,
|
inline: false,
|
||||||
},
|
},
|
||||||
games.length > 0 && {
|
games.length > 0 && {
|
||||||
name: "Associated Games",
|
name: "Associated Games",
|
||||||
value: gameLines,
|
value: gamesLeft,
|
||||||
inline: false,
|
|
||||||
},
|
|
||||||
gameLines2 != "" && {
|
|
||||||
name: "\u200b",
|
|
||||||
value: gameLines2,
|
|
||||||
inline: false,
|
|
||||||
},
|
|
||||||
clan.badge_color_primary && {
|
|
||||||
name: "Badge Colors",
|
|
||||||
value: `${clan.badge_color_primary}, ${clan.badge_color_secondary}`,
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
clan.brand_color_primary && {
|
gamesRight != "" && {
|
||||||
|
name: "\u200b",
|
||||||
|
value: gamesRight,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
games.length > 0 && {
|
||||||
|
name: "\u200b",
|
||||||
|
value: "\u200b",
|
||||||
|
inline: false,
|
||||||
|
},
|
||||||
|
profile.badge_color_primary && {
|
||||||
|
name: "Badge Colors",
|
||||||
|
value: `${profile.badge_color_primary}, ${profile.badge_color_secondary}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
profile.brand_color_primary && {
|
||||||
name: "Banner/Brand Colors",
|
name: "Banner/Brand Colors",
|
||||||
value: `${clan.brand_color_primary}${clan.brand_color_secondary ? `, ${clan.brand_color_secondary}` : ""}`,
|
value: `${profile.brand_color_primary}${
|
||||||
|
profile.brand_color_secondary ? `, ${profile.brand_color_secondary}` : ""
|
||||||
|
}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (clan.badge_hash) {
|
if (profile.badge_hash) {
|
||||||
const url = CDNEndpoints.CLAN_BADGE(clan.id, clan.badge_hash);
|
const url = CDNEndpoints.CLAN_BADGE(profile.id, profile.badge_hash);
|
||||||
images.push(`[Badge](${url})`);
|
images.push(`[Badge](${url})`);
|
||||||
clanEmbed.author.icon_url = url;
|
clanEmbed.author.icon_url = url;
|
||||||
}
|
}
|
||||||
if (clan.banner_hash) {
|
if (profile.banner_hash) {
|
||||||
const url = CDNEndpoints.CLAN_BANNER(clan.id, clan.banner_hash);
|
const url = CDNEndpoints.CLAN_BANNER(profile.id, profile.banner_hash);
|
||||||
images.push(`[Banner](${url})`);
|
images.push(`[Banner](${url})`);
|
||||||
clanEmbed.image = {url};
|
clanEmbed.image = {url};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue