decord/source/modules/guild_boosting/RoleIconUtils.tsx

102 lines
3.2 KiB
TypeScript
Raw Normal View History

2026-08-07 06:50:47 +00:00
// Module ID: 5693
// Function ID: 5694
2026-07-29 08:29:29 +00:00
// Name: getRoleIconData
2026-08-07 06:50:47 +00:00
// Dependencies: [676, 500, 3942, 1450, 1416, 2]
2026-07-20 16:05:17 +00:00
// Exports: canGuildUseRoleIcons, getRoleIconData, isRoleIconAssetUrl, replaceRoleIconSourceSize
2026-08-07 06:50:47 +00:00
// Module 5693 (getRoleIconData)
2026-07-23 10:11:24 +00:00
import ME from "ME";
import set from "set";
2026-07-29 08:29:29 +00:00
import set from "parseRawEmojiObject";
2026-07-23 10:11:24 +00:00
2026-07-29 08:29:29 +00:00
let c3;
let c4;
({ Endpoints: c3, GuildFeatures: c4 } = ME);
2026-07-20 16:05:17 +00:00
let closure_5 = "" + location.protocol + "//" + window.GLOBAL_ENV.CDN_HOST + "/role-icons";
let closure_6 = "" + location.protocol + window.GLOBAL_ENV.API_ENDPOINT;
2026-07-23 10:11:24 +00:00
set = set.isAndroid();
const result = set.fileFinishedImporting("modules/guild_boosting/RoleIconUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getRoleIconData = function getRoleIconData(role, arg1) {
2026-07-29 08:29:29 +00:00
let icon;
let id;
2026-07-20 16:05:17 +00:00
if (null == role) {
return null;
} else {
let byName;
if (null != role.unicodeEmoji) {
2026-08-07 06:50:47 +00:00
let obj = importDefault(3942);
byName = obj.getByName(importDefault(3942).convertSurrogateToName(role.unicodeEmoji, false));
const obj2 = importDefault(3942);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
({ id, icon } = role);
let tmp4;
if (null != icon) {
tmp4 = icon;
if (!icon.startsWith("data:")) {
let str2 = "png";
if (require(1416) /* getAvatarURL */.SUPPORTS_WEBP) {
str2 = "webp";
}
let str3 = "quality=lossless";
let str5 = "";
if (null != arg1) {
tmp5(1450);
tmp5(1450);
let str7 = "";
const text = `size=${tmp9(arg1 * obj3.getDevicePixelRatio())}`;
if (!set) {
str7 = "&quality=lossless";
}
str3 = str7;
str5 = text;
}
let str8 = globalThis;
const _window = window;
if (null != window.GLOBAL_ENV.CDN_HOST) {
str8 = "/";
let combined = "" + closure_5 + "/" + id + "/" + icon + "." + str2 + "?" + str5 + str3;
} else {
const _HermesInternal = HermesInternal;
combined = "" + closure_6 + closure_3.ROLE_ICON(id, icon) + "?" + str5;
}
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { customIconSrc: null, unicodeEmoji: null };
obj[0] = tmp4;
obj[1] = byName;
2026-07-20 16:05:17 +00:00
return obj;
}
};
export const replaceRoleIconSourceSize = function replaceRoleIconSourceSize(str) {
2026-07-31 08:44:05 +00:00
const obj = require(1450) /* handleImageLoad */;
return str.replace(/size=[0-9]+/g, "size=" + obj.getBestMediaProxySize(arg1 * require(1450) /* handleImageLoad */.getDevicePixelRatio()));
2026-07-20 16:05:17 +00:00
};
export const isRoleIconAssetUrl = function isRoleIconAssetUrl(str) {
let startsWithResult = str.startsWith(closure_5);
if (!startsWithResult) {
const _HermesInternal = HermesInternal;
let startsWithResult1 = str.startsWith("" + closure_6 + "/roles");
if (startsWithResult1) {
startsWithResult1 = str.includes("/icons/");
}
startsWithResult = startsWithResult1;
}
return startsWithResult;
};
export const canGuildUseRoleIcons = function canGuildUseRoleIcons(guild, role) {
let prop;
2026-07-29 08:29:29 +00:00
if (role != null) {
2026-07-20 16:05:17 +00:00
const tags = role.tags;
2026-07-29 08:29:29 +00:00
if (tags != null) {
2026-07-20 16:05:17 +00:00
prop = tags.subscription_listing_id;
}
}
let hasItem = null != prop;
if (!hasItem) {
const features = guild.features;
hasItem = features.has(constants.ROLE_ICONS);
}
return hasItem;
};