Files
discord-decomp/modules/guild_automod/AutomodErrorUtils.tsx
T
2026-11-01 12:12:55 +02:00

70 lines
2.5 KiB
TypeScript

// Metro module 6178 (f6179).
import ChannelStore from "../../stores/ChannelStore";
import { AbortCodes } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import { isMessageDataEdit } from "../../lib/MessageQueue";
let c3919_4, getAutomodErrorMessageFromMessageData, InvalidKeywordError;
const getAutomodErrorMessageFromErrorResponse = function getAutomodErrorMessageFromErrorResponse(a0, a1) {
if (a0 == null) {
return null;
}
const { code, message } = a0;
if (c3919_4.has(code)) {
if (message != null) {
return message;
}
if (a1 == null) {
return null;
}
const channel = ChannelStore.getChannel(a1);
if (channel == null ? void 0 : channel.isThread()) {
return intl.string(t.DVdG9E);
}
if (!(!(channel == null ? void 0 : channel.isForumPost()) && !(channel == null ? void 0 : channel.isForumLikeChannel()))) {
if (code === AbortCodes.AUTOMOD_TITLE_BLOCKED) {
return intl.string(t.ipgKDg);
}
if (code === AbortCodes.AUTOMOD_MESSAGE_BLOCKED) {
return intl.string(t.ipgKDg);
}
}
return null;
}
return null;
};
getAutomodErrorMessageFromMessageData = function getAutomodErrorMessageFromMessageData(a0) {
let r32;
L16: {
const channel = ChannelStore.getChannel(a0.message.channelId);
if (isMessageDataEdit(a0)) {
r32 = intl.string(t.bU6o0z);
} else if (channel == null ? void 0 : channel.isThread()) {
r32 = intl.string(t.DVdG9E);
} else {
if (!(channel == null ? void 0 : channel.isForumPost()) && !(channel == null ? void 0 : channel.isForumLikeChannel())) {
r32 = intl.string(t.zQ69pv);
break L16;
}
r32 = intl.string(t.ipgKDg);
}
}
return r32;
};
const InvalidKeywordError2 = class InvalidKeywordError extends Error {};
InvalidKeywordError2.prototype;
InvalidKeywordError = InvalidKeywordError2;
class InvalidRegexPatternError extends Error {}
c3919_4 = new Set([AbortCodes.AUTOMOD_MESSAGE_BLOCKED, AbortCodes.AUTOMOD_TITLE_BLOCKED, AbortCodes.AUTOMOD_INVALID_RUST_SERVICE_RESPONSE]);
export { InvalidKeywordError };
export { InvalidRegexPatternError };
export { c3919_4 as AUTOMOD_ERROR_CODES };
export { getAutomodErrorMessageFromErrorResponse };
export { getAutomodErrorMessageFromMessageData };
export function getAutomodErrorMessage(a0, a1) {
let r8 = getAutomodErrorMessageFromErrorResponse(a1);
if (r8 == null) {
r8 = a0 == null ? intl.string(t.zQ69pv) : getAutomodErrorMessageFromMessageData(a0);
}
return r8;
}