utility.decoration: more info and cleaner layout
This commit is contained in:
parent
5a967de4cd
commit
4e6c5b88cd
1 changed files with 52 additions and 12 deletions
|
@ -1055,9 +1055,9 @@ decoration.callback = async function (msg, line, [user]) {
|
||||||
"/users/" + id,
|
"/users/" + id,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
let decor;
|
let decor, decorRes;
|
||||||
try {
|
try {
|
||||||
const decorRes = await fetch(
|
decorRes = await fetch(
|
||||||
`https://decor.fieryflames.dev/api/users/${id}/decoration`,
|
`https://decor.fieryflames.dev/api/users/${id}/decoration`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1067,6 +1067,21 @@ decoration.callback = async function (msg, line, [user]) {
|
||||||
}
|
}
|
||||||
).then((res) => res.json());
|
).then((res) => res.json());
|
||||||
|
|
||||||
|
if (decorRes.presetId) {
|
||||||
|
// horror
|
||||||
|
const presets = await fetch(
|
||||||
|
`https://decor.fieryflames.dev/api/decorations/presets`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"User-Agent":
|
||||||
|
"HiddenPhox/decoration (https://gitdab.com/Cynosphere/HiddenPhox)",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
).then((res) => res.json());
|
||||||
|
|
||||||
|
decorRes.preset = presets.find((p) => p.id === decorRes.presetId);
|
||||||
|
}
|
||||||
|
|
||||||
decor = `https://decorcdn.fieryflames.dev/${decorRes.animated ? "a_" : ""}${
|
decor = `https://decorcdn.fieryflames.dev/${decorRes.animated ? "a_" : ""}${
|
||||||
decorRes.hash
|
decorRes.hash
|
||||||
}.png`;
|
}.png`;
|
||||||
|
@ -1085,17 +1100,42 @@ decoration.callback = async function (msg, line, [user]) {
|
||||||
title: `Decoration for \`${formatUsername(userObj)}\``,
|
title: `Decoration for \`${formatUsername(userObj)}\``,
|
||||||
};
|
};
|
||||||
|
|
||||||
baseEmbed.description = (
|
baseEmbed.fields = [];
|
||||||
(normalUrl ? `[Normal decoration](${normalUrl})` : "") +
|
|
||||||
(decor ? `\n[Decor decoration](${decor})` : "")
|
|
||||||
).trim();
|
|
||||||
|
|
||||||
if (
|
if (normalUrl) {
|
||||||
userObj.avatar_decoration_data?.asset.startsWith("a_") ||
|
const listing = await hf.bot.requestHandler
|
||||||
decor?.indexOf("/a_") > -1
|
.request(
|
||||||
) {
|
"GET",
|
||||||
baseEmbed.description += "\n(Animated decoration, open in browser to view)";
|
`/store/published-listings/skus/${userObj.avatar_decoration_data.sku_id}`,
|
||||||
baseEmbed.description = baseEmbed.description.trim();
|
true
|
||||||
|
)
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
|
baseEmbed.fields.push({
|
||||||
|
name: `Discord ${
|
||||||
|
userObj.avatar_decoration_data.asset.startsWith("a_")
|
||||||
|
? "(Animated)"
|
||||||
|
: ""
|
||||||
|
}`,
|
||||||
|
value: `**${
|
||||||
|
listing?.sku
|
||||||
|
? `[${listing?.sku?.name}](https://discord.com/shop#itemSkuId=${userObj.avatar_decoration_data.sku_id})`
|
||||||
|
: "Unknown"
|
||||||
|
}** (\`${
|
||||||
|
userObj.avatar_decoration_data.sku_id
|
||||||
|
}\`)\n[Image](${normalUrl})`,
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decor) {
|
||||||
|
baseEmbed.fields.push({
|
||||||
|
name: `Decor ${decor.indexOf("/a_") > -1 ? "(Animated)" : ""}`,
|
||||||
|
value: `**${decorRes.alt}**\n${
|
||||||
|
decorRes.preset ? ` from preset **${decorRes.preset.name}**\n` : ""
|
||||||
|
}[Image](${decor})`,
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
baseEmbed.url = normalUrl || decor;
|
baseEmbed.url = normalUrl || decor;
|
||||||
|
|
Loading…
Reference in a new issue