2026-09-28 16:18:32 +00:00
|
|
|
// Module ID: 8596
|
|
|
|
|
// Function ID: 8597
|
2026-09-18 19:45:33 +00:00
|
|
|
// Name: CommandPermissionContext
|
2026-09-28 16:18:32 +00:00
|
|
|
// Dependencies: [19, 2101, 2049, 2063, 502, 2045, 2108, 2067, 4469, 1372, 1074, 8597, 504, 1086, 1979, 2]
|
2026-09-18 19:45:33 +00:00
|
|
|
// Exports: buildPermissionContext, computeCommandContextType, getContextGuildId, usePermissionContext
|
|
|
|
|
|
2026-09-28 16:18:32 +00:00
|
|
|
// Module 8596 (CommandPermissionContext)
|
2026-09-26 17:57:22 +00:00
|
|
|
import BigFlagUtilsAll from "BigFlagUtils" /* 1086 */;
|
2026-09-28 16:18:32 +00:00
|
|
|
import Server from "Server" /* 1979 */;
|
2026-10-01 14:13:23 +00:00
|
|
|
import ChannelRecord from "ChannelRecord" /* 2049 */;
|
|
|
|
|
import GuildRecord from "GuildRecord" /* 2063 */;
|
2026-09-28 16:18:32 +00:00
|
|
|
import AgeRestrictedContentSettingsUtils from "AgeRestrictedContentSettingsUtils" /* 8597 */;
|
2026-10-01 14:13:23 +00:00
|
|
|
import react_mod from "react" /* 19 */;
|
2026-09-28 16:18:32 +00:00
|
|
|
import ImpersonateStore from "ImpersonateStore" /* 2101 */;
|
2026-09-18 19:45:33 +00:00
|
|
|
import AuthenticationStore from "AuthenticationStore" /* 502 */;
|
2026-09-28 16:18:32 +00:00
|
|
|
import ChannelStore from "ChannelStore" /* 2045 */;
|
|
|
|
|
import GuildMemberStore from "GuildMemberStore" /* 2108 */;
|
|
|
|
|
import GuildStore from "GuildStore" /* 2067 */;
|
|
|
|
|
import PermissionStore from "PermissionStore" /* 4469 */;
|
2026-09-26 17:57:22 +00:00
|
|
|
import UserStore from "UserStore" /* 1372 */;
|
2026-10-01 14:13:23 +00:00
|
|
|
import Constants from "Constants" /* 1074 */;
|
|
|
|
|
import size from "module_2" /* 2 */;
|
2026-09-18 19:45:33 +00:00
|
|
|
|
|
|
|
|
const require = globalThis.__r;
|
2026-10-01 14:13:23 +00:00
|
|
|
let _require;
|
2026-09-18 19:45:33 +00:00
|
|
|
|
2026-10-01 14:13:23 +00:00
|
|
|
let closure_14;
|
|
|
|
|
let map1;
|
2026-09-18 19:45:33 +00:00
|
|
|
function computePermissions(isPrivate, arg1) {
|
2026-10-01 14:13:23 +00:00
|
|
|
let deserializer;
|
2026-09-18 19:45:33 +00:00
|
|
|
if (!(isPrivate instanceof ChannelRecordBase)) {
|
|
|
|
|
if (null != isPrivate) {
|
|
|
|
|
const permissions = PermissionStore.computePermissions(isPrivate);
|
|
|
|
|
let flag = true;
|
|
|
|
|
let flag2 = true;
|
2026-10-01 14:13:23 +00:00
|
|
|
const obj5 = BigFlagUtilsAll;
|
2026-09-18 19:45:33 +00:00
|
|
|
if (!obj5.has(permissions, constants2.ADMINISTRATOR)) {
|
2026-10-01 14:13:23 +00:00
|
|
|
const tmp3 = isPrivate instanceof tmp;
|
|
|
|
|
const tmp11Result = BigFlagUtilsAll;
|
|
|
|
|
const hasItem = tmp11Result.has(permissions, tmp13.VIEW_CHANNEL);
|
2026-09-18 19:45:33 +00:00
|
|
|
if (tmp3) {
|
2026-10-01 14:13:23 +00:00
|
|
|
let hasItem2;
|
2026-09-18 19:45:33 +00:00
|
|
|
let hasItem1 = hasItem;
|
2026-10-01 14:13:23 +00:00
|
|
|
if (hasItem1) {
|
|
|
|
|
const tmp11Result3 = BigFlagUtilsAll;
|
|
|
|
|
hasItem1 = tmp11Result3.has(permissions, tmp13.USE_APPLICATION_COMMANDS);
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
const has = BigFlagUtilsAll.has;
|
|
|
|
|
BigFlagUtilsAll;
|
2026-09-18 19:45:33 +00:00
|
|
|
if (arg1) {
|
2026-10-01 14:13:23 +00:00
|
|
|
hasItem2 = has(permissions, tmp13.SEND_MESSAGES_IN_THREADS);
|
2026-09-18 19:45:33 +00:00
|
|
|
} else {
|
2026-10-01 14:13:23 +00:00
|
|
|
hasItem2 = has(permissions, tmp13.SEND_MESSAGES);
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
flag = hasItem2;
|
|
|
|
|
flag2 = hasItem1;
|
2026-09-18 19:45:33 +00:00
|
|
|
} else {
|
|
|
|
|
flag = true;
|
|
|
|
|
flag2 = hasItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
return { computedPermissions: permissions, hasBaseAccessPermissions: flag2, hasSendMessagesPermission: flag };
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
const obj2 = { computedPermissions: deserializer.deserialize(0), hasBaseAccessPermissions: true, hasSendMessagesPermission: true };
|
|
|
|
|
deserializer = BigFlagUtilsAll;
|
2026-09-18 19:45:33 +00:00
|
|
|
return obj2;
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
let react = react_mod;
|
|
|
|
|
const ChannelRecordBase = ChannelRecord.ChannelRecordBase;
|
|
|
|
|
const isGuildNSFW = GuildRecord.isGuildNSFW;
|
2026-09-18 19:45:33 +00:00
|
|
|
({ ChannelTypes: map1, Permissions: closure_14 } = Constants);
|
|
|
|
|
const result = size.fileFinishedImporting("modules/application_commands/CommandPermissionContext.tsx");
|
|
|
|
|
|
|
|
|
|
export const buildPermissionContext = function buildPermissionContext(channel, items) {
|
2026-10-01 14:13:23 +00:00
|
|
|
let tmp16;
|
2026-09-18 19:45:33 +00:00
|
|
|
let obj = channel;
|
|
|
|
|
if (channel instanceof ChannelRecordBase) {
|
|
|
|
|
obj = channel;
|
|
|
|
|
if (channel.isThread()) {
|
|
|
|
|
channel = ChannelStore.getChannel(channel.parent_id);
|
|
|
|
|
obj = channel;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
let tmp5;
|
|
|
|
|
if (null != obj) {
|
|
|
|
|
tmp5 = obj instanceof tmp ? obj.guild_id : obj.id;
|
|
|
|
|
}
|
|
|
|
|
const obj2 = AgeRestrictedContentSettingsUtils;
|
|
|
|
|
let viewNsfwCommandsOrDefault = obj2.getViewNsfwCommandsOrDefault();
|
|
|
|
|
const id = AuthenticationStore.getId();
|
|
|
|
|
const currentUser = UserStore.getCurrentUser();
|
|
|
|
|
let flag;
|
|
|
|
|
if (currentUser != null) {
|
|
|
|
|
flag = currentUser.nsfwAllowed;
|
|
|
|
|
}
|
|
|
|
|
if (flag == null) {
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
if (null != tmp5) {
|
|
|
|
|
const member = GuildMemberStore.getMember(tmp5, id);
|
|
|
|
|
let roles;
|
|
|
|
|
if (member != null) {
|
|
|
|
|
roles = member.roles;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
if (roles == null) {
|
|
|
|
|
roles = [];
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
items = roles;
|
|
|
|
|
} else {
|
|
|
|
|
items = [];
|
|
|
|
|
}
|
|
|
|
|
let isThreadResult = channel instanceof tmp;
|
|
|
|
|
const isViewingRolesResult = ImpersonateStore.isViewingRoles(tmp5);
|
|
|
|
|
const tmp12 = computePermissions;
|
|
|
|
|
if (isThreadResult) {
|
|
|
|
|
isThreadResult = channel.isThread();
|
|
|
|
|
}
|
|
|
|
|
const tmp12Result = tmp12(obj, isThreadResult);
|
|
|
|
|
const obj3 = { context: obj, userId: id, roleIds: items, isImpersonating: isViewingRolesResult, commandTypes: items, computedPermissions: tmp12Result.computedPermissions, hasBaseAccessPermissions: tmp12Result.hasBaseAccessPermissions, hasSendMessagesPermission: tmp12Result.hasSendMessagesPermission, allowNsfw: tmp16 };
|
|
|
|
|
tmp16 = flag;
|
|
|
|
|
if (tmp16) {
|
|
|
|
|
let tmp17 = !(obj instanceof tmp);
|
|
|
|
|
if (!tmp17) {
|
|
|
|
|
if (null != obj.guild_id) {
|
|
|
|
|
viewNsfwCommandsOrDefault = obj.isNSFW() || tmp15;
|
|
|
|
|
obj.isNSFW() || tmp15;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
tmp17 = viewNsfwCommandsOrDefault;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
tmp16 = tmp17;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
return obj3;
|
2026-09-18 19:45:33 +00:00
|
|
|
};
|
|
|
|
|
export const usePermissionContext = function usePermissionContext(channel, items) {
|
2026-10-01 14:13:23 +00:00
|
|
|
let closure_3;
|
|
|
|
|
let stateFromStoresArray;
|
2026-09-26 17:57:22 +00:00
|
|
|
_require = channel;
|
|
|
|
|
const commandTypes = items;
|
2026-10-01 14:13:23 +00:00
|
|
|
let obj = react;
|
2026-09-26 17:57:22 +00:00
|
|
|
items = [channel];
|
2026-10-01 14:13:23 +00:00
|
|
|
const memo = react.useMemo(() => {
|
|
|
|
|
let tmp = channel;
|
|
|
|
|
if (channel instanceof ChannelRecordBase) {
|
2026-09-26 17:57:22 +00:00
|
|
|
tmp = obj;
|
2026-10-01 14:13:23 +00:00
|
|
|
if (channel.isThread()) {
|
|
|
|
|
channel = ChannelStore.getChannel(obj.parent_id);
|
2026-09-26 17:57:22 +00:00
|
|
|
if (channel == null) {
|
|
|
|
|
channel = obj;
|
|
|
|
|
}
|
|
|
|
|
tmp = channel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}, items);
|
2026-10-01 14:13:23 +00:00
|
|
|
let tmp;
|
|
|
|
|
if (null != memo) {
|
|
|
|
|
tmp = memo instanceof stateFromStoresArray ? memo.guild_id : memo.id;
|
|
|
|
|
}
|
|
|
|
|
react = tmp;
|
|
|
|
|
const obj3 = require("AgeRestrictedContentSettingsUtils");
|
|
|
|
|
let viewNsfwCommandsOrDefault = obj3.useViewNsfwCommandsOrDefault();
|
|
|
|
|
const items1 = [viewNsfwCommandsOrDefault];
|
|
|
|
|
const obj4 = require("get initialized");
|
|
|
|
|
const stateFromStores = obj4.useStateFromStores(items1, () => viewNsfwCommandsOrDefault.getId());
|
|
|
|
|
const items2 = [UserStore];
|
|
|
|
|
const obj5 = require("get initialized");
|
|
|
|
|
const stateFromStores1 = obj5.useStateFromStores(items2, () => {
|
|
|
|
|
currentUser = currentUser.getCurrentUser();
|
|
|
|
|
let flag;
|
|
|
|
|
if (currentUser != null) {
|
|
|
|
|
flag = currentUser.nsfwAllowed;
|
|
|
|
|
}
|
|
|
|
|
if (flag == null) {
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
});
|
|
|
|
|
const items3 = [GuildMemberStore];
|
|
|
|
|
const obj6 = require("get initialized");
|
|
|
|
|
stateFromStoresArray = obj6.useStateFromStoresArray(items3, () => {
|
|
|
|
|
let items;
|
|
|
|
|
if (null != closure_3) {
|
|
|
|
|
const member = GuildMemberStore.getMember(tmp, stateFromStores);
|
|
|
|
|
let roles;
|
|
|
|
|
if (member != null) {
|
|
|
|
|
roles = member.roles;
|
2026-09-26 17:57:22 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
if (roles == null) {
|
|
|
|
|
roles = [];
|
2026-09-26 17:57:22 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
items = roles;
|
|
|
|
|
} else {
|
|
|
|
|
items = [];
|
2026-09-26 17:57:22 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
return items;
|
|
|
|
|
});
|
|
|
|
|
const items4 = [stateFromStores];
|
|
|
|
|
const obj7 = require("get initialized");
|
|
|
|
|
const stateFromStores2 = obj7.useStateFromStores(items4, () => ImpersonateStore.isViewingRoles(closure_3));
|
|
|
|
|
require("get initialized");
|
|
|
|
|
[][0] = tmp;
|
|
|
|
|
let tmp10 = stateFromStores1;
|
|
|
|
|
if (tmp10) {
|
|
|
|
|
let tmp12 = !(memo instanceof stateFromStoresArray);
|
|
|
|
|
if (!tmp12) {
|
|
|
|
|
if (null != memo.guild_id) {
|
|
|
|
|
viewNsfwCommandsOrDefault = memo.isNSFW() || tmp9;
|
|
|
|
|
memo.isNSFW() || tmp9;
|
2026-09-26 17:57:22 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
tmp12 = viewNsfwCommandsOrDefault;
|
|
|
|
|
}
|
|
|
|
|
tmp10 = tmp12;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
viewNsfwCommandsOrDefault = tmp10;
|
|
|
|
|
const items5 = [items, memo, stateFromStores2, stateFromStoresArray, stateFromStores, tmp10, channel];
|
|
|
|
|
return obj.useMemo(() => {
|
|
|
|
|
let isThreadResult = channel instanceof ChannelRecordBase;
|
|
|
|
|
const obj = channel;
|
|
|
|
|
const tmp = computePermissions;
|
|
|
|
|
if (isThreadResult) {
|
|
|
|
|
isThreadResult = obj.isThread();
|
|
|
|
|
}
|
|
|
|
|
const tmpResult = tmp(memo, isThreadResult);
|
|
|
|
|
return { context: memo, userId: stateFromStores, roleIds: stateFromStoresArray, commandTypes, isImpersonating: stateFromStores2, computedPermissions: tmpResult.computedPermissions, hasBaseAccessPermissions: tmpResult.hasBaseAccessPermissions, hasSendMessagesPermission: tmpResult.hasSendMessagesPermission, allowNsfw: viewNsfwCommandsOrDefault };
|
|
|
|
|
}, items5);
|
2026-09-18 19:45:33 +00:00
|
|
|
};
|
|
|
|
|
export const computeCommandContextType = function computeCommandContextType(channel, applicationId) {
|
|
|
|
|
if (channel instanceof ChannelRecordBase) {
|
2026-10-01 14:13:23 +00:00
|
|
|
let GUILD;
|
2026-09-18 19:45:33 +00:00
|
|
|
let guild_id;
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
guild_id = channel.guild_id;
|
|
|
|
|
}
|
|
|
|
|
if (null == guild_id) {
|
|
|
|
|
let type;
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
type = channel.type;
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
if (type === map1.DM) {
|
|
|
|
|
let PRIVATE_CHANNEL;
|
2026-09-18 19:45:33 +00:00
|
|
|
let recipientId;
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
recipientId = channel.getRecipientId();
|
|
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
if (recipientId === applicationId) {
|
|
|
|
|
PRIVATE_CHANNEL = Server.InteractionContextType.BOT_DM;
|
|
|
|
|
}
|
|
|
|
|
GUILD = PRIVATE_CHANNEL;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
PRIVATE_CHANNEL = Server.InteractionContextType.PRIVATE_CHANNEL;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
return GUILD;
|
2026-09-18 19:45:33 +00:00
|
|
|
}
|
2026-10-01 14:13:23 +00:00
|
|
|
GUILD = Server.InteractionContextType.GUILD;
|
2026-09-18 19:45:33 +00:00
|
|
|
};
|
|
|
|
|
export const getContextGuildId = function getContextGuildId(context) {
|
|
|
|
|
return context instanceof ChannelRecordBase ? context.guild_id : context.id;
|
|
|
|
|
};
|