decord/source/modules/replies/canReplyToMessage.tsx
2026-09-03 10:05:34 +00:00

115 lines
3.7 KiB
TypeScript

// Module ID: 7897
// Function ID: 7898
// Name: useCanReplyToMessage
// Dependencies: [32, 4120, 1921, 673, 502, 683, 6125, 7898, 586, 2]
// Exports: canReplyToMessage, useCanReplyToMessage
// Module 7897 (useCanReplyToMessage)
import useCanStartPrivateThread from "useCanStartPrivateThread" /* 6125 */;
import useUserCommunicationDisabled from "useUserCommunicationDisabled" /* 7898 */;
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "getUncachedChannelPermissions" /* 4120 */;
import closure_4 from "mergeGuildAvatar" /* 1921 */;
import ME from "ME" /* 673 */;
import { Permissions } from "sum" /* 502 */;
require = arg1;
({ MessageFlags: c5, MessageStates: closure_6 } = ME);
const result = require("set").fileFinishedImporting("modules/replies/canReplyToMessage.tsx");
export const useCanReplyToMessage = function useCanReplyToMessage(channel, message) {
const _require = channel;
dependencyMap = message;
const canUnarchiveThread = _require(6125).useCanUnarchiveThread(channel);
const obj = _require(6125);
let tmp = _require;
let guildId;
if (channel != null) {
guildId = channel.getGuildId();
}
const obj2 = _require(7898);
const items = [closure_3];
let stateFromStores = tmp(586).useStateFromStores(items, () => {
let tmp = null != channel;
if (tmp) {
tmp = null != message;
}
if (tmp) {
if (obj.isPrivate()) {
let hasItem = !obj.isSystemDM();
} else {
hasItem = obj2.can(closure_1_7.SEND_MESSAGES, obj) && obj2.can(closure_1_7.READ_MESSAGE_HISTORY, obj);
const tmp4 = closure_1_7;
}
if (hasItem) {
const REPLYABLE = channel(message[5]).MessageTypesSets.REPLYABLE;
hasItem = REPLYABLE.has(tmp3.type);
}
tmp = hasItem;
tmp3 = message;
}
return tmp;
});
let tmp6 = null != channel && null != message;
if (tmp6) {
const isArchivedThreadResult = channel.isArchivedThread();
let tmp11 = !isArchivedThreadResult;
if (isArchivedThreadResult) {
tmp11 = canUnarchiveThread;
}
if (stateFromStores) {
stateFromStores = message.state === constants2.SENT;
}
if (stateFromStores) {
stateFromStores = !hasFlagResult;
}
if (stateFromStores) {
stateFromStores = !callback(obj2.useCurrentUserCommunicationDisabled(guildId), 2)[1];
}
if (stateFromStores) {
stateFromStores = tmp11;
}
tmp6 = stateFromStores;
hasFlagResult = message.hasFlag(constants.EPHEMERAL);
}
return tmp6;
};
export const canReplyToMessage = function canReplyToMessage(isPrivate, type) {
const obj = useCanStartPrivateThread;
if (isPrivate.isPrivate()) {
let hasItem = !isPrivate.isSystemDM();
} else {
hasItem = obj2.can(Permissions.SEND_MESSAGES, isPrivate) && obj2.can(Permissions.READ_MESSAGE_HISTORY, isPrivate);
const tmp4 = Permissions;
}
if (hasItem) {
const REPLYABLE = tmp(683).MessageTypesSets.REPLYABLE;
hasItem = REPLYABLE.has(type.type);
}
currentUser = currentUser.getCurrentUser();
const canUnarchiveThreadResult = useCanStartPrivateThread.canUnarchiveThread(isPrivate);
let id;
if (currentUser != null) {
id = currentUser.id;
}
const guildId = isPrivate.getGuildId();
const tmpResult = useUserCommunicationDisabled;
const isArchivedThreadResult = isPrivate.isArchivedThread();
let tmp11 = !isArchivedThreadResult;
if (isArchivedThreadResult) {
tmp11 = canUnarchiveThreadResult;
}
if (hasItem) {
hasItem = type.state === constants2.SENT;
}
if (hasItem) {
hasItem = !hasFlagResult;
}
if (hasItem) {
hasItem = !callback(tmpResult.userCommunicationDisabled(id, guildId), 2)[1];
}
if (hasItem) {
hasItem = tmp11;
}
return hasItem;
};