decord/source/modules/guild_automod/GuildAutomodActionCreators.tsx
github-actions a36fe4ec9c chore: update source for alpha 347.0
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-14 20:04:03 +00:00

328 lines
12 KiB
TypeScript

// Module ID: 11998
// Function ID: 11999
// Name: GuildAutomodActionCreators
// Dependencies: [5, 2015, 1979, 4275, 1074, 11999, 1369, 11, 1270, 11992, 4816, 7621, 573, 2]
// Exports: clearMentionRaidDetected, createAutomodRule, deleteAutomodRule, executeAlertAction, fetchAutomodRules, removeMentionRaidRestrictionWithFeedback, updateAutomodRule, validateAutomodRule
// Module 11998 (GuildAutomodActionCreators)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import HTTPUtils from "HTTPUtils" /* 1270 */;
import GlobalUtils from "GlobalUtils" /* 1369 */;
import AppAnalyticsUtils from "AppAnalyticsUtils" /* 4816 */;
import AutomodFeedback from "AutomodFeedback" /* 7621 */;
import DataUtils from "DataUtils" /* 11999 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import PermissionStore from "PermissionStore" /* 4275 */;
const require = globalThis.__r;
require = fn;
function _transformClientActionToApiAction(type) {
const obj = { type: type.type, metadata: DataUtils._transformMetadataToSnakeCase(type.metadata) };
return obj;
}
function _transformClientRuleToApiRule(id) {
_require = id;
const result = require("DataUtils")._transformMetadataToSnakeCase(id.triggerMetadata);
if (null != result) {
delete tmp2[tmp];
}
const obj3 = { id: id.id, name: id.name, guild_id: id.guildId, event_type: id.eventType, trigger_type: id.triggerType, trigger_metadata: result, actions: null, enabled: null, creator_id: null, position: null, exempt_channels: null, exempt_roles: null };
const actions = id.actions;
const found = actions.filter(require("GlobalUtils").isNotNullish);
obj3.actions = found.map(_transformClientActionToApiAction);
({ enabled: obj2.enabled, creatorId: obj2.creator_id, position: obj2.position } = id);
let exemptChannels = id.exemptChannels;
if (exemptChannels == null) {
exemptChannels = [];
}
obj3.exempt_channels = Array.from(exemptChannels);
let exemptRoles = id.exemptRoles;
if (exemptRoles == null) {
exemptRoles = [];
}
const obj = require("DataUtils");
obj3.exempt_roles = Array.from(exemptRoles).filter((item) => null != GuildRoleStore.getRole(guildId.guildId, item));
return obj3;
}
function _transformApiActionToClientAction(type) {
const obj = { type: type.type, metadata: DataUtils._transformMetadataToCamelCase(type.metadata) };
return obj;
}
function _transformApiRuletoClientRule(id) {
id = id.id;
if (id == null) {
const _Date = Date;
id = SnowflakeUtilsDefault.fromTimestamp(Date.now());
}
const obj4 = { id, name: id.name, guildId: id.guild_id, eventType: id.event_type, triggerType: id.trigger_type, triggerMetadata: DataUtils._transformMetadataToCamelCase(id.trigger_metadata), actions: null, enabled: null, creatorId: null, position: null, exemptChannels: null, exemptRoles: null };
const actions = id.actions;
const found = actions.filter(GlobalUtils.isNotNullish);
obj4.actions = found.map(_transformApiActionToClientAction);
({ enabled: obj2.enabled, creator_id: obj2.creatorId, position: obj2.position } = id);
let exempt_channels = id.exempt_channels;
if (exempt_channels == null) {
exempt_channels = [];
}
obj4.exemptChannels = new Set(exempt_channels);
let exempt_roles = id.exempt_roles;
if (exempt_roles == null) {
exempt_roles = [];
}
const set = new Set(exempt_channels);
obj4.exemptRoles = new Set(exempt_roles);
if (null != obj4.triggerMetadata) {
const triggerMetadata = obj4.triggerMetadata;
delete tmp2[tmp];
}
return obj4;
}
let closure_14 = async function _validateAutomodRule(arg0) {
let guildId = arg0;
c3 = 0;
c4 = 0;
return (async (arg0) => {
closure_2 = tmp3;
closure_1 = tmp2;
const HTTP = require("HTTPUtils").HTTP;
const request = { url: closure_2_8.GUILD_AUTOMOD_VALIDATE_RULE(guildId.guildId), body: _transformClientRuleToApiRule(guildId), rejectWithError: null };
_transformClientRuleToApiRule(guildId);
request.rejectWithError = require("HTTPUtils").rejectWithMigratedError();
closure_129_0 = await HTTP.post(request);
return closure_130_0(closure_130_2[5])._transformMetadataToCamelCase(closure_129_0.body);
})();
};
let closure_15 = async function _createAutomodRule(arg0) {
let guildId = arg0;
c2 = 0;
c3 = 0;
return (async (arg0, value) => {
delete tmp3[tmp2];
closure_1 = _transformApiRuletoClientRule;
const HTTP = require("HTTPUtils").HTTP;
const request = { url: closure_2_8.GUILD_AUTOMOD_RULES(guildId.guildId), body: _transformClientRuleToApiRule(guildId), rejectWithError: null };
_transformClientRuleToApiRule(guildId);
request.rejectWithError = require("HTTPUtils").rejectWithMigratedError();
await HTTP.post(request);
return closure_1(value.body);
})();
};
let closure_16 = async function _updateAutomodRule() {
importDefault = _transformApiRuletoClientRule;
const HTTP = require("HTTPUtils").HTTP;
const request = { url: React6.GUILD_AUTOMOD_RULE(_require.guildId, _require.id), body: _transformClientRuleToApiRule(_require), rejectWithError: null };
_transformClientRuleToApiRule(_require);
request.rejectWithError = require("HTTPUtils").rejectWithMigratedError();
await HTTP.patch(request);
return importDefault(arg1.body);
};
let closure_17 = async function _deleteAutomodRule() {
const HTTP = require("HTTPUtils").HTTP;
await HTTP.del({ url: closure_2_8.GUILD_AUTOMOD_RULE(closure_1, closure_0), rejectWithError: require("HTTPUtils").rejectWithMigratedError() });
return true;
};
let closure_18 = async function _fetchAutomodRules(arg0, value) {
if (c4 === 2) {
c4 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c4 = 2;
if (0 === c3) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj3 = { value, done: true };
return obj3;
} else {
closure_2 = tmp2;
closure_1 = tmp5;
closure_129_0 = undefined;
const HTTP = require("HTTPUtils").HTTP;
const obj4 = { url: React6.GUILD_AUTOMOD_RULES(closure_0), rejectWithError: require("HTTPUtils").rejectWithMigratedError() };
c3 = 1;
c4 = 1;
const obj5 = { value: HTTP.get(obj4), done: false };
return obj5;
}
} else if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj = { value, done: true };
return obj;
} else {
closure_129_0 = value;
const _Array = Array;
if (Array.isArray(closure_129_0.body)) {
const body = closure_129_0.body;
const mapped = body.map(closure_130_13);
} else {
const items = [];
}
c4 = 3;
}
} catch (tmp14) {
c4 = tmp;
throw tmp14;
}
}
};
let closure_19 = async function _executeAlertAction(arg0, value) {
if (c3 === 2) {
c3 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c3 = 2;
if (0 === c4) {
if (arg0 === 1) {
c3 = 3;
throw value;
} else if (arg0 === 2) {
c3 = 3;
const obj3 = { value, done: true };
return obj3;
} else {
if (PermissionStore.can(constants.MANAGE_MESSAGES, closure_1)) {
const HTTP = require("HTTPUtils").HTTP;
const request = { url: React6.GUILD_AUTOMOD_ALERT_ACTION(tmp14.guild_id), body: null, rejectWithError: null };
const obj5 = { message_id: tmp13, channel_id: tmp14.id, alert_action_type: tmp15 };
request.body = obj5;
request.rejectWithError = require("HTTPUtils").rejectWithMigratedError();
c4 = 1;
c3 = 1;
const obj6 = { value: HTTP.post(request), done: false };
return obj6;
}
tmp13 = closure_0;
tmp15 = closure_2;
}
} else if (arg0 === 1) {
c3 = 3;
throw value;
} else if (arg0 === 2) {
c3 = 3;
const obj = { value, done: true };
return obj;
}
c3 = 3;
return { value: "HermesInternal", done: null };
} catch (tmp8) {
c3 = tmp;
throw tmp8;
}
}
};
const Constants = fn(1074);
({ AnalyticEvents: closure_7, Endpoints: closure_8, Permissions: closure_9 } = Constants);
const size = fn(2);
let result = size.fileFinishedImporting("modules/guild_automod/GuildAutomodActionCreators.tsx");
export const validateAutomodRule = function validateAutomodRule() {
const self = this;
const apply = closure_14.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const createAutomodRule = function createAutomodRule() {
const self = this;
const apply = closure_15.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const updateAutomodRule = function updateAutomodRule() {
const self = this;
const apply = closure_16.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const deleteAutomodRule = function deleteAutomodRule() {
const self = this;
const apply = closure_17.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const fetchAutomodRules = function fetchAutomodRules() {
const self = this;
const apply = closure_18.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const executeAlertAction = function executeAlertAction() {
const self = this;
const apply = closure_19.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const removeMentionRaidRestrictionWithFeedback = function removeMentionRaidRestrictionWithFeedback(arg0, decision_id, arg2) {
_require = arg0;
dependencyMap = arg2;
const guild = GuildStore.getGuild(arg0);
let canResult = null != guild;
if (canResult) {
canResult = PermissionStore.can(constants2.MANAGE_GUILD, guild);
}
if (canResult) {
const result = require("GuildAutomodActionActionCreators").openConfirmRemoveMentionRaid(() => {
const obj = AppAnalyticsUtils;
obj.trackWithMetadata(constants.GUILD_AUTOMOD_FEEDBACK, { feedback_type: AutomodFeedback.Feedback.MENTION_RAID_REMOVE_RESTRICTION, decision_id });
const HTTP = HTTPUtils.HTTP;
const obj2 = { feedback_type: AutomodFeedback.Feedback.MENTION_RAID_REMOVE_RESTRICTION, decision_id };
HTTP.post({ url: React6.GUILD_AUTOMOD_CLEAR_MENTION_RAID(closure_0), rejectWithError: true });
closure_2();
});
let obj = require("GuildAutomodActionActionCreators");
}
};
export const clearMentionRaidDetected = function clearMentionRaidDetected(guildId) {
DispatcherDefault.dispatch({ type: "AUTO_MODERATION_MENTION_RAID_NOTICE_DISMISS", guildId });
};