Files
discord-decomp/records/GuildRecord.tsx
T
2026-11-01 12:12:55 +02:00

115 lines
3.7 KiB
TypeScript

// Metro module 1415 (f1416).
import { set, TypeTag } from "../lib/PlainRecord";
import * as _Constants from "../Constants";
import { GuildNSFWContentLevel, MFALevels } from "../Constants";
import AvatarUtils from "../utils/AvatarUtils";
import { getAcronym } from "../utils/StringUtils";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import { isServerNSFWLevelEnabled } from "../modules/age_gate/ServerNSFWLevelExperiment";
TypeTag;
const { BoostedGuildTiers, GuildExplicitContentFilterTypes, UserNotificationSettings, VerificationLevels } = _Constants;
let c1170_6 = new Set([GuildNSFWContentLevel.EXPLICIT, GuildNSFWContentLevel.AGE_RESTRICTED]);
const r49 = Object.freeze({
mfaLevel: MFALevels.NONE,
preferredLocale: "en-US",
afkTimeout: 0,
defaultMessageNotifications: UserNotificationSettings.ALL_MESSAGES,
verificationLevel: VerificationLevels.NONE,
explicitContentFilter: GuildExplicitContentFilterTypes.DISABLED,
premiumProgressBarEnabled: false,
premiumProgressBarEnabledUserUpdatedAt: null,
systemChannelFlags: 0,
maxStageVideoChannelUsers: -1,
maxVideoChannelUsers: -1,
maxMembers: -1,
premiumTier: BoostedGuildTiers.NONE,
nsfwLevel: GuildNSFWContentLevel.DEFAULT,
premiumSubscriberCount: 0,
features: new Set(),
description: null,
icon: null,
ownerId: null,
systemChannelId: null,
joinedAt: null,
discoverySplash: null,
splash: null,
banner: null,
homeHeader: null,
afkChannelId: null,
application_id: null,
vanityURLCode: null,
rulesChannelId: null,
safetyAlertsChannelId: null,
publicUpdatesChannelId: null,
ownerConfiguredContentLevel: null,
hubType: null,
latestOnboardingQuestionId: null,
profile: null,
guildTheme: null,
premiumFeatures: null,
moderatorReporting: null,
verificationRoleId: null,
gameApplicationIds: null,
officialMessageColor: null
});
export const GuildRecordTypeTag = "Guild";
export { c1170_6 as RESTRICTED_CONTENT_LEVELS };
export { r49 as GUILD_DEFAULT_PROPERTY_VALUES };
export function getGuildIconURL(a0, a1, canAnimate = false, lossless = false) {
return AvatarUtils.getGuildIconURL({
id: a0.id,
size: a1,
icon: a0.icon,
canAnimate,
lossless
});
}
export function getGuildIconSource(c13030_0, size, r5 = false) {
return AvatarUtils.getAnimatableSourceWithFallback(r5, (a0) => AvatarUtils.getGuildIconSource({
id: c13030_0.id,
size,
icon: c13030_0.icon,
canAnimate: a0
}));
}
export function getGuildAcronym(a0) {
return getAcronym(a0.name);
}
export function isGuildOwner(a0, a1) {
return a0.ownerId === (typeof a1 !== "string" ? a1 != null ? a1.id : null : a1);
}
export function isGuildOwnerWithRequiredMfaLevel(a0, a1) {
const mfaEnabled = a1.mfaEnabled;
const r0 = mfaEnabled ? !mfaEnabled : a0.mfaLevel === MFALevels.ELEVATED;
return r0 ? !r0 : a0.ownerId === (typeof a1 !== "string" ? a1 != null ? a1.id : null : a1);
}
export function isGuildLurker(a0) {
return a0.joinedAt == null;
}
export function getGuildEveryoneRoleId(a0) {
return SnowflakeUtils.castGuildIdAsEveryoneGuildRoleId(a0.id);
}
export function updateJoinedAt(a0, a1) {
return set(a0, "joinedAt", typeof a1 === "string" ? new Date(a1) : a1);
}
export function updateGameApplications(a0, a1) {
return set(a0, "gameApplicationIds", a1);
}
export function isGuildNSFW(a0) {
let r16;
let r2 = a0 != null;
if (r2) {
if (isServerNSFWLevelEnabled("guild_record")) {
r16 = c1170_6.has(a0.nsfwLevel);
} else {
let ownerConfiguredContentLevel = a0.ownerConfiguredContentLevel;
if (ownerConfiguredContentLevel == null) {
ownerConfiguredContentLevel = GuildNSFWContentLevel.DEFAULT;
}
r16 = c1170_6.has(ownerConfiguredContentLevel);
}
r2 = r16;
}
return r2;
}