decord/source/modules/guild_antiraid/GuildAntiRaidUtils.tsx

188 lines
6.9 KiB
TypeScript
Raw Normal View History

// Module ID: 8089
// Function ID: 8090
// Name: GuildAntiRaidUtils
// Dependencies: [8090, 4198, 8091, 1114, 2]
2026-07-29 08:29:29 +00:00
// Exports: getDisabledInterventions, getEnabledInterventions, getIncidentAlertType, getSecurityActionDetailsString, hasDMsDisabled, hasDetectedActivity, hasDetectedDMRaid, hasDetectedRaid, hasInvitesDisabled, initialLockdownDurationHours, isUnderLockdown
2026-07-20 16:05:17 +00:00
// Module 8089 (GuildAntiRaidUtils)
import util from "util" /* 1114 */;
import _modDef4198 from "module_4198" /* 4198 */;
import GuildAntiRaidTypes from "GuildAntiRaidTypes" /* 8091 */;
import GuildAntiRaidConstants from "GuildAntiRaidConstants" /* 8090 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
({ NAGBAR_DISPLAY_MAX_HOURS: c3, DEFAULT_LOCKDOWN_DURATION: closure_4, getTimeframes: hasOwnProperty } = GuildAntiRaidConstants);
let date = { month: "numeric", day: "numeric", hour: "numeric", minute: "2-digit" };
const result = size.fileFinishedImporting("modules/guild_antiraid/GuildAntiRaidUtils.tsx");
2026-07-20 16:05:17 +00:00
export const DATE_CONFIG = date;
2026-08-06 08:05:19 +00:00
export const hasDetectedActivity = function hasDetectedActivity(incidentsData) {
let tmp = null != incidentsData.dmSpamDetectedAt;
2026-07-20 16:05:17 +00:00
if (tmp) {
const obj = _modDef4198(incidentsData.dmSpamDetectedAt);
tmp = _modDef4198(incidentsData.dmSpamDetectedAt).add(React3, "hours") > _modDef4198();
const addResult = _modDef4198(incidentsData.dmSpamDetectedAt).add(React3, "hours");
2026-07-20 16:05:17 +00:00
}
if (!tmp) {
2026-08-06 08:05:19 +00:00
let tmp6 = null != incidentsData.raidDetectedAt;
2026-07-20 16:05:17 +00:00
if (tmp6) {
const obj2 = _modDef4198(incidentsData.raidDetectedAt);
tmp6 = _modDef4198(incidentsData.raidDetectedAt).add(React3, "hours") > _modDef4198();
const addResult1 = _modDef4198(incidentsData.raidDetectedAt).add(React3, "hours");
2026-07-20 16:05:17 +00:00
}
tmp = tmp6;
}
return tmp;
};
2026-07-29 08:29:29 +00:00
export const hasDetectedRaid = function hasDetectedRaid(raidDetectedAt) {
let tmp = null != raidDetectedAt.raidDetectedAt;
if (tmp) {
const obj = _modDef4198(raidDetectedAt.raidDetectedAt);
tmp = _modDef4198(raidDetectedAt.raidDetectedAt).add(React3, "hours") > _modDef4198();
const addResult = _modDef4198(raidDetectedAt.raidDetectedAt).add(React3, "hours");
2026-07-29 08:29:29 +00:00
}
return tmp;
};
2026-07-20 16:05:17 +00:00
export const hasDetectedDMRaid = function hasDetectedDMRaid(dmSpamDetectedAt) {
let tmp = null != dmSpamDetectedAt.dmSpamDetectedAt;
if (tmp) {
const obj = _modDef4198(dmSpamDetectedAt.dmSpamDetectedAt);
tmp = _modDef4198(dmSpamDetectedAt.dmSpamDetectedAt).add(React3, "hours") > _modDef4198();
const addResult = _modDef4198(dmSpamDetectedAt.dmSpamDetectedAt).add(React3, "hours");
2026-07-20 16:05:17 +00:00
}
return tmp;
};
export const getIncidentAlertType = function getIncidentAlertType(guildIncident) {
if (null != guildIncident) {
2026-07-29 08:29:29 +00:00
let tmp = null != guildIncident.raidDetectedAt;
if (tmp) {
const obj = _modDef4198(guildIncident.raidDetectedAt);
tmp = _modDef4198(guildIncident.raidDetectedAt).add(React3, "hours") > _modDef4198();
const addResult = _modDef4198(guildIncident.raidDetectedAt).add(React3, "hours");
2026-07-29 08:29:29 +00:00
}
const GuildIncidentAlertTypes = GuildAntiRaidTypes.GuildIncidentAlertTypes;
2026-07-20 16:05:17 +00:00
}
};
export const getEnabledInterventions = function getEnabledInterventions(pauseInvites, pauseDms) {
const items = [];
if (pauseInvites) {
items.push(GuildAntiRaidTypes.GuildIncidentActionTypes.INVITES_DISABLED);
2026-07-20 16:05:17 +00:00
}
if (pauseDms) {
items.push(GuildAntiRaidTypes.GuildIncidentActionTypes.DMS_DISABLED);
2026-07-20 16:05:17 +00:00
}
return items;
};
export const getDisabledInterventions = function getDisabledInterventions(pauseInvites, pauseDms) {
const items = [];
if (!pauseInvites) {
items.push(GuildAntiRaidTypes.GuildIncidentActionTypes.INVITES_DISABLED);
2026-07-20 16:05:17 +00:00
}
if (!pauseDms) {
items.push(GuildAntiRaidTypes.GuildIncidentActionTypes.DMS_DISABLED);
2026-07-20 16:05:17 +00:00
}
return items;
};
2026-08-06 08:05:19 +00:00
export const isUnderLockdown = function isUnderLockdown(incidentsData) {
let tmp = null != incidentsData.dmsDisabledUntil;
2026-07-20 16:05:17 +00:00
if (tmp) {
const _Date = Date;
date = new Date(incidentsData.dmsDisabledUntil);
2026-07-20 16:05:17 +00:00
const _Date2 = Date;
const date1 = new Date();
tmp = date > date1;
}
if (!tmp) {
2026-08-06 08:05:19 +00:00
let tmp11 = null != incidentsData.invitesDisabledUntil;
2026-07-20 16:05:17 +00:00
if (tmp11) {
const _Date3 = Date;
2026-08-06 08:05:19 +00:00
const date2 = new Date(incidentsData.invitesDisabledUntil);
2026-07-20 16:05:17 +00:00
const _Date4 = Date;
const date3 = new Date();
tmp11 = date2 > date3;
}
tmp = tmp11;
}
return tmp;
};
export const hasDMsDisabled = function hasDMsDisabled(stateFromStores) {
let dmsDisabledUntil;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
dmsDisabledUntil = stateFromStores.dmsDisabledUntil;
}
let tmp2 = null != dmsDisabledUntil;
if (tmp2) {
const _Date = Date;
date = new Date(stateFromStores.dmsDisabledUntil);
2026-07-20 16:05:17 +00:00
const _Date2 = Date;
const date1 = new Date();
tmp2 = date > date1;
}
return tmp2;
};
export const hasInvitesDisabled = function hasInvitesDisabled(stateFromStores) {
let invitesDisabledUntil;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
invitesDisabledUntil = stateFromStores.invitesDisabledUntil;
}
let tmp2 = null != invitesDisabledUntil;
if (tmp2) {
const _Date = Date;
date = new Date(stateFromStores.invitesDisabledUntil);
2026-07-20 16:05:17 +00:00
const _Date2 = Date;
const date1 = new Date();
tmp2 = date > date1;
}
return tmp2;
};
export const initialLockdownDurationHours = function initialLockdownDurationHours(stateFromStores) {
let prop;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
prop = stateFromStores.lockdownDurationHours;
}
if (null == prop) {
prop = React4;
2026-07-20 16:05:17 +00:00
} else {
const obj = hasOwnProperty();
2026-07-20 16:05:17 +00:00
}
return prop;
};
export const getSecurityActionDetailsString = function getSecurityActionDetailsString(dmsDisabledUntil, guildName) {
2026-07-20 16:05:17 +00:00
let invitesDisabledUntil = dmsDisabledUntil.dmsDisabledUntil;
2026-07-29 08:29:29 +00:00
if (invitesDisabledUntil == null) {
2026-07-20 16:05:17 +00:00
invitesDisabledUntil = dmsDisabledUntil.invitesDisabledUntil;
}
if (null == invitesDisabledUntil) {
return "";
} else {
2026-07-29 08:29:29 +00:00
let tmp = tmp27;
2026-07-20 16:05:17 +00:00
if (null != dmsDisabledUntil.dmsDisabledUntil) {
2026-07-29 08:29:29 +00:00
tmp = tmp28;
2026-07-20 16:05:17 +00:00
}
if (tmp === true) {
const intl3 = util.intl;
const obj2 = { guildName, time: null };
2026-07-20 16:05:17 +00:00
const _Date3 = Date;
date = new Date(invitesDisabledUntil);
obj2.time = date.toLocaleString(util.intl.currentLocale, date);
return intl3.formatToPlainString(util.t.hCZitf, obj2);
2026-07-29 08:29:29 +00:00
} else if (tmp27 === true) {
const intl2 = util.intl;
const obj3 = { guildName, time: null };
2026-07-20 16:05:17 +00:00
const _Date2 = Date;
const date1 = new Date(invitesDisabledUntil);
obj3.time = date1.toLocaleString(util.intl.currentLocale, date);
return intl2.formatToPlainString(util.t["HNKxf+"], obj3);
2026-07-29 08:29:29 +00:00
} else if (tmp28 === true) {
const intl = util.intl;
const obj = { guildName, time: null };
2026-07-20 16:05:17 +00:00
const _Date = Date;
const date2 = new Date(invitesDisabledUntil);
obj.time = date2.toLocaleString(util.intl.currentLocale, date);
return intl.formatToPlainString(util.t.M3iSyL, obj);
2026-07-20 16:05:17 +00:00
} else {
return "";
}
}
};