decord/source/modules/guild_automod/AutomodStore.tsx

472 lines
13 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 16855
// Function ID: 16856
2026-07-29 08:29:29 +00:00
// Name: withEqualityFn
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 5, 19, 11081, 676, 700, 16856, 705, 11086, 4277, 4009, 2]
2026-07-29 08:29:29 +00:00
// Exports: getRuleCountByTriggerType, useAutomodRulesList, useSyncAutomodRules, useSyncAutomodRulesEffect
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 16855 (withEqualityFn)
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "noop" /* 19 */;
import { AutomodTriggerType } from "AutomodEventType" /* 11081 */;
import { EMPTY_STRING_SNOWFLAKE_ID } from "ME" /* 676 */;
import identity from "identity" /* 700 */;
2026-07-23 10:11:24 +00:00
2026-07-29 08:29:29 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
let closure_7 = {};
2026-07-29 08:29:29 +00:00
const withEqualityFn = identity.createWithEqualityFn((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
2026-07-23 10:11:24 +00:00
let obj = {
2026-07-20 16:05:17 +00:00
rules: {},
2026-07-23 10:11:24 +00:00
fetching: false,
error: null,
2026-07-20 16:05:17 +00:00
updateRule(guildId) {
2026-07-23 10:11:24 +00:00
const callback = guildId;
2026-07-20 16:05:17 +00:00
guildId = guildId.guildId;
2026-08-24 06:08:38 +00:00
({ id: closure_2, triggerType } = guildId);
2026-07-23 10:11:24 +00:00
const rules = guildId().rules;
2026-07-20 16:05:17 +00:00
let obj = rules[guildId];
2026-07-29 08:29:29 +00:00
if (obj == null) {
2026-07-20 16:05:17 +00:00
obj = {};
}
let items = obj[triggerType];
2026-07-29 08:29:29 +00:00
if (items == null) {
2026-07-20 16:05:17 +00:00
items = [];
}
const found = items.filter((id) => {
2026-07-29 08:29:29 +00:00
const isDefaultRuleIdResult = guildId(guildId2[6]).isDefaultRuleId(id.id);
let tmp2 = !isDefaultRuleIdResult;
if (isDefaultRuleIdResult) {
tmp2 = id.triggerType !== triggerType;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
});
if (someResult) {
let mapped = found.map((id) => {
let tmp = id;
2026-08-24 06:08:38 +00:00
if (id.id === closure_2) {
2026-07-23 10:11:24 +00:00
tmp = closure_0;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
} else {
mapped = [];
2026-07-29 08:29:29 +00:00
mapped[HermesBuiltin.arraySpread(found, 0)] = guildId;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
someResult = items.some((id) => id.id === closure_2);
2026-07-29 08:29:29 +00:00
callback(705).batchUpdates(() => {
2026-08-24 06:08:38 +00:00
obj = { rules: null, error: null };
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(rules);
obj = {};
const merged1 = Object.assign(obj);
obj[triggerType] = mapped;
obj[guildId] = obj;
2026-07-29 08:29:29 +00:00
obj[0] = obj;
2026-07-23 10:11:24 +00:00
guildId(obj);
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
},
removeRule(arg0, arg1) {
const callback = arg0;
2026-08-24 06:08:38 +00:00
dependencyMap = arg1;
2026-07-29 08:29:29 +00:00
const rules = dependencyMap().rules;
2026-08-24 06:08:38 +00:00
closure_3 = tmp;
2026-07-29 08:29:29 +00:00
const keys = Object.keys(tmp);
2026-08-24 06:08:38 +00:00
closure_4 = keys.reduce((arg0, arg1) => {
2026-07-29 08:29:29 +00:00
const NumberResult = Number(arg1);
2026-08-24 06:08:38 +00:00
let items = table[NumberResult];
2026-07-29 08:29:29 +00:00
if (items == null) {
items = [];
}
arg0[NumberResult] = items.filter((id) => id.id !== closure_0);
return arg0;
}, {});
callback(705).batchUpdates(() => {
let obj = { rules: null, error: null };
obj = {};
const merged = Object.assign(rules);
2026-08-24 06:08:38 +00:00
obj[closure_1] = closure_4;
2026-07-29 08:29:29 +00:00
obj[0] = obj;
callback(obj);
});
},
syncRules: null
2026-07-20 16:05:17 +00:00
};
2026-08-24 06:08:38 +00:00
closure_2 = callback((arg0) => {
closure_0 = arg0;
c6 = 0;
c7 = 0;
c4 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0) {
if (c7 === 2) {
c7 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c7 = 2;
if (0 === c6) {
if (arg0 === 1) {
c7 = 3;
throw arg1;
} else if (arg0 === 2) {
c7 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
let aPIError = tmp3;
let rules = tmp7;
let callback2;
rules = undefined;
aPIError = undefined;
if ((function isSyncNeeded(closure_0) {
let num = table[closure_0];
const timestamp = Date.now();
if (num == null) {
num = 0;
}
return timestamp - num > 20000;
})(callback)) {
const _Date = Date;
c7[tmp41] = Date.now();
2026-08-24 06:08:38 +00:00
c4 = 1;
2026-07-29 08:29:29 +00:00
callback2 = function convertToRulesByTriggerType(arr) {
const obj = { [closure_5.KEYWORD]: [], [closure_5.ML_SPAM]: [], [closure_5.DEFAULT_KEYWORD_LIST]: [], [closure_5.MENTION_SPAM]: [], [closure_5.USER_PROFILE]: [], [closure_5.SERVER_POLICY]: [] };
const item = arr.forEach((arg0) => {
let arr = obj[arg0.triggerType];
if (arr != null) {
arr = arr.push(arg0);
}
});
return obj;
};
c6 = 2;
c7 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
obj1[0] = callback(closure_1_1[8]).fetchAutomodRules(tmp41);
2026-07-29 08:29:29 +00:00
return obj1;
}
}
} else {
if (1 === tmp7) {
c4 = 0;
c4 = closure_5;
2026-08-24 06:08:38 +00:00
aPIError = new callback(closure_1_1[9]).APIError(c4);
let obj2 = callback(closure_1_1[7]);
2026-07-29 08:29:29 +00:00
obj2.batchUpdates(() => {
callback({ error: aPIError });
});
} else if (arg0 === 1) {
c7 = 3;
throw arg1;
} else if (arg0 !== 2) {
callback2 = callback2(arg1);
rules = callback2().rules;
2026-08-24 06:08:38 +00:00
obj = callback(closure_1_1[7]);
2026-07-29 08:29:29 +00:00
obj.batchUpdates(() => {
let obj = { rules: null, error: null };
obj = {};
const merged = Object.assign(rules);
obj[callback] = closure_1;
obj[0] = obj;
callback(obj);
});
c4 = 0;
}
c4 = 0;
c7 = 3;
obj2 = { value: null, done: true };
obj2[0] = arg1;
return obj2;
}
c7 = 3;
} catch (tmp32) {
closure_5 = tmp32;
if (tmp4 === c4) {
c7 = tmp2;
throw tmp32;
} else {
c6 = tmp;
}
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
})();
});
obj[5] = function() {
const self = this;
2026-08-24 06:08:38 +00:00
const apply = closure_2.apply;
2026-07-29 08:29:29 +00:00
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};
return obj;
});
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/guild_automod/AutomodStore.tsx");
2026-07-20 16:05:17 +00:00
export const useAutomodStore = withEqualityFn;
2026-07-29 08:29:29 +00:00
export const getRuleCountByTriggerType = function getRuleCountByTriggerType(arg0, arg1) {
const tmp = withEqualityFn.getState().rules[arg0];
2026-07-20 16:05:17 +00:00
let items;
2026-07-29 08:29:29 +00:00
if (tmp != null) {
items = tmp[arg1];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (items == null) {
2026-07-20 16:05:17 +00:00
items = [];
}
return items.length;
};
2026-07-29 08:29:29 +00:00
export const useSyncAutomodRules = function useSyncAutomodRules(arg0) {
const _require = arg0;
const tmp = first(React.useState(false), 2);
2026-08-24 06:08:38 +00:00
dependencyMap = tmp[1];
2026-07-29 08:29:29 +00:00
const tmp2 = first(withEqualityFn((arg0) => {
const items = [, ];
({ syncRules: arr[0], fetching: arr[1] } = arg0);
return items;
2026-08-24 06:08:38 +00:00
}, _require(4009).shallow), 2);
2026-07-29 08:29:29 +00:00
first = tmp2[0];
const callback = tmp4;
const items = [tmp[0], ];
const items1 = [arg0, tmp2[1], first];
items[1] = React.useCallback(callback(function*() {
if (c4 === 2) {
c4 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c4 = 2;
if (0 === v0) {
if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_0 = tmp3;
2026-07-29 08:29:29 +00:00
if (!c3) {
2026-08-24 06:08:38 +00:00
if (null != closure_1_0) {
2026-07-29 08:29:29 +00:00
c3 = 1;
v0(true);
v0 = 2;
c4 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
obj1[0] = closure_1_2(tmp20);
2026-07-29 08:29:29 +00:00
return obj1;
}
}
c4 = 3;
}
} else if (1 === tmp7) {
c3 = 0;
v0(false);
2026-08-24 06:08:38 +00:00
throw closure_2;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 !== 2) {
c3 = 0;
v0(false);
}
c3 = 0;
v0(false);
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} catch (tmp24) {
2026-08-24 06:08:38 +00:00
closure_2 = tmp24;
2026-07-29 08:29:29 +00:00
if (tmp4 === c3) {
c4 = tmp2;
throw tmp24;
} else {
v0 = tmp;
}
}
}
}), items1);
return items;
};
2026-07-20 16:05:17 +00:00
export const useSyncAutomodRulesEffect = function useSyncAutomodRulesEffect(arg0) {
2026-07-29 08:29:29 +00:00
let _require = arg0;
const tmp = first(React.useState(false), 2);
2026-08-24 06:08:38 +00:00
dependencyMap = tmp[1];
2026-07-29 08:29:29 +00:00
const tmp2 = first(withEqualityFn((arg0) => {
const items = [, ];
({ syncRules: arr[0], fetching: arr[1] } = arg0);
return items;
2026-08-24 06:08:38 +00:00
}, _require(4009).shallow), 2);
2026-07-29 08:29:29 +00:00
first = tmp2[0];
const callback = tmp4;
let items = [tmp[0], ];
const items1 = [arg0, tmp2[1], first];
items[1] = React.useCallback(callback(function*() {
if (c4 === 2) {
c4 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c4 = 2;
if (0 === v0) {
if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_0 = tmp3;
2026-07-29 08:29:29 +00:00
if (!c3) {
2026-08-24 06:08:38 +00:00
if (null != closure_1_0) {
2026-07-29 08:29:29 +00:00
c3 = 1;
v0(true);
v0 = 2;
c4 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
obj1[0] = closure_1_2(tmp20);
2026-07-29 08:29:29 +00:00
return obj1;
}
}
c4 = 3;
}
} else if (1 === tmp7) {
c3 = 0;
v0(false);
2026-08-24 06:08:38 +00:00
throw closure_2;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 1) {
c4 = 3;
throw arg1;
} else if (arg0 !== 2) {
c3 = 0;
v0(false);
}
c3 = 0;
v0(false);
c4 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} catch (tmp24) {
2026-08-24 06:08:38 +00:00
closure_2 = tmp24;
2026-07-29 08:29:29 +00:00
if (tmp4 === c3) {
c4 = tmp2;
throw tmp24;
} else {
v0 = tmp;
}
}
}
}), items1);
const tmp5 = first(items, 2);
_require = tmp6;
const items2 = [arg0, tmp5[1]];
2026-07-20 16:05:17 +00:00
const effect = React.useEffect(() => {
2026-08-24 06:08:38 +00:00
callback(function*() {
2026-07-29 08:29:29 +00:00
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
v0 = 2;
if (0 === c1) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
c1 = 1;
v0 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = v0();
return obj1;
}
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
v0 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} catch (tmp6) {
v0 = tmp;
throw tmp6;
}
}
})();
}, items2);
const items3 = [tmp5[0], tmp5[1]];
return items3;
2026-07-20 16:05:17 +00:00
};
export const useAutomodRulesList = function useAutomodRulesList(arg0) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-07-29 08:29:29 +00:00
return withEqualityFn((updateRule) => {
let tmp = closure_0;
if (closure_0 == null) {
2026-08-24 06:08:38 +00:00
tmp = closure_1_6;
2026-07-29 08:29:29 +00:00
}
let obj = updateRule.rules[tmp];
if (obj == null) {
2026-07-20 16:05:17 +00:00
obj = {};
}
2026-07-29 08:29:29 +00:00
obj = { rulesByTriggerType: obj, updateRule: updateRule.updateRule, removeRule: updateRule.removeRule };
2026-07-20 16:05:17 +00:00
return obj;
2026-08-24 06:08:38 +00:00
}, _require(4009).shallow);
2026-07-20 16:05:17 +00:00
};