2026-07-24 07:16:23 +00:00
// Module ID: 8220
// Function ID: 64779
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-24 07:16:23 +00:00
// Dependencies: [1352, 1838, 4566, 653, 8221, 8012, 6755, 1881, 483, 8224, 44, 6753, 6754, 2]
2026-07-20 16:05:17 +00:00
// Exports: hasAccess
2026-07-24 07:16:23 +00:00
// Module 8220 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import { ChannelRecordBase } from "_callSuper" ;
import _createForOfIteratorHelperLoose from "_createForOfIteratorHelperLoose" ;
import { BuiltInSectionId } from "TRUE_OPTION_NAME" ;
import { Permissions } from "ME" ;
function _createForOfIteratorHelperLoose ( iterable ) {
let closure_0 = iterable ;
iterable = "undefined" !== typeof Symbol ;
if ( iterable ) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol ;
2026-07-23 10:11:24 +00:00
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( ! iterable ) {
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( iterable ) {
const iter = iterable . call ( iterable ) ;
2026-07-20 16:05:17 +00:00
const next = iter . next ;
return next . bind ( iter ) ;
} else {
const _Array = Array ;
2026-07-23 10:11:24 +00:00
let tmp = iterable ;
if ( ! Array . isArray ( iterable ) ) {
2026-07-20 16:05:17 +00:00
let tmp2 ;
2026-07-23 10:11:24 +00:00
if ( iterable ) {
if ( "string" === typeof iterable ) {
tmp2 = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
const toString = { } . toString ;
2026-07-23 10:11:24 +00:00
const substr = toString . call ( iterable ) . slice ( 8 , - 1 ) ;
2026-07-20 16:05:17 +00:00
let name = substr ;
if ( tmp3 ) {
2026-07-23 10:11:24 +00:00
name = iterable . constructor . name ;
2026-07-20 16:05:17 +00:00
}
if ( "Map" !== name ) {
if ( "Set" !== name ) {
if ( "Arguments" === name ) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ ;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr ;
}
const _Array2 = Array ;
2026-07-23 10:11:24 +00:00
arr = Array . from ( iterable ) ;
const callResult = toString . call ( iterable ) ;
tmp3 = "Object" === substr && iterable . constructor ;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2 ;
if ( ! tmp2 ) {
const _TypeError = TypeError ;
const typeError = new TypeError ( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
throw typeError ;
}
}
if ( tmp ) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0 ;
2026-07-20 16:05:17 +00:00
return ( ) = > {
2026-07-23 10:11:24 +00:00
if ( closure_1 >= length . length ) {
2026-07-20 16:05:17 +00:00
let obj = { done : true } ;
} else {
obj = { done : false } ;
closure_1 = tmp3 + 1 ;
2026-07-23 10:11:24 +00:00
obj . value = length [ + closure_1 ] ;
2026-07-20 16:05:17 +00:00
}
return obj ;
} ;
}
}
function _arrayLikeToArray ( arg0 , arg1 ) {
let length ;
if ( tmp ) {
length = arg0 . length ;
}
const ArrayResult = Array ( length ) ;
for ( let num = 0 ; num < length ; num = num + 1 ) {
ArrayResult [ num ] = arg0 [ num ] ;
}
return ArrayResult ;
}
function isExplicitAllow ( arg0 ) {
return true === arg0 ;
}
function isExplicitDeny ( applicationAllowedForChannel ) {
return false === applicationAllowedForChannel ;
}
function computeAllowedForChannel ( permissions , context , guild_id ) {
if ( null == permissions ) {
return null ;
} else {
let id2 = context . id ;
if ( context . isThread ( ) ) {
let id = context . parent_id ;
if ( null == id ) {
id = context . id ;
}
id2 = id ;
}
2026-07-23 10:11:24 +00:00
const obj = require ( 6754 ) /* toPermissionKey */ ;
const tmp3 = permissions [ obj . toPermissionKey ( obj , id2 , require ( undefined , 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandPermissionType . CHANNEL ) ] ;
if ( null != tmp3 ) {
2026-07-20 16:05:17 +00:00
return tmp3 . permission ;
} else {
2026-07-23 10:11:24 +00:00
const obj2 = require ( 6754 ) /* toPermissionKey */ ;
const obj3 = require ( 6753 ) /* _createForOfIteratorHelperLoose */ ;
const tmp8 = permissions [ obj2 . toPermissionKey ( obj2 , require ( 6753 ) /* _createForOfIteratorHelperLoose */ . allChannelsSentinel ( guild_id ) , require ( undefined , 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandPermissionType . CHANNEL ) ] ;
2026-07-20 16:05:17 +00:00
let permission = null ;
2026-07-23 10:11:24 +00:00
if ( null != tmp8 ) {
2026-07-20 16:05:17 +00:00
permission = tmp8 . permission ;
}
return permission ;
}
}
}
function computeAllowedForUser ( permissions , guild_id , userId , roleIds , isImpersonating ) {
if ( null == permissions ) {
return null ;
} else {
if ( ! isImpersonating ) {
2026-07-23 10:11:24 +00:00
const obj = require ( 6754 ) /* toPermissionKey */ ;
const tmp4 = permissions [ obj . toPermissionKey ( obj , userId , require ( undefined , 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandPermissionType . USER ) ] ;
if ( null != tmp4 ) {
2026-07-20 16:05:17 +00:00
return tmp4 . permission ;
}
}
const tmp7 = _createForOfIteratorHelperLoose ( roleIds ) ;
const iter = tmp7 ( ) ;
let iter2 = iter ;
let flag3 = false ;
let flag4 = false ;
if ( ! iter . done ) {
while ( true ) {
let tmp8 = require ;
let tmp9 = dependencyMap ;
2026-07-23 10:11:24 +00:00
let obj2 = require ( 6754 ) /* toPermissionKey */ ;
let tmp10 = permissions [ obj2 . toPermissionKey ( obj2 , iter2 . value , require ( undefined , 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandPermissionType . ROLE ) ] ;
2026-07-20 16:05:17 +00:00
if ( null != tmp10 ) {
flag3 = true ;
if ( tmp10 . permission ) {
break ;
}
}
let iter3 = tmp7 ( ) ;
iter2 = iter3 ;
flag4 = flag3 ;
}
return true ;
}
if ( flag4 ) {
return false ;
} else {
let tmp11 = null ;
if ( null != guild_id ) {
2026-07-23 10:11:24 +00:00
const obj3 = require ( 6754 ) /* toPermissionKey */ ;
tmp11 = permissions [ obj3 . toPermissionKey ( obj3 , guild_id , require ( undefined , 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandPermissionType . ROLE ) ] ;
2026-07-20 16:05:17 +00:00
}
let permission = null ;
if ( null != tmp11 ) {
permission = tmp11 . permission ;
}
return permission ;
}
}
}
2026-07-23 10:11:24 +00:00
let obj = { ALLOWED : 0 , [ 0 ] : "ALLOWED" , NSFW_NOT_ALLOWED : 1 , [ 1 ] : "NSFW_NOT_ALLOWED" , WRONG_COMMAND_TYPE : 2 , [ 2 ] : "WRONG_COMMAND_TYPE" , PREDICATE_FAILED : 3 , [ 3 ] : "PREDICATE_FAILED" , CONTEXT_NOT_ALLOWED : 4 , [ 4 ] : "CONTEXT_NOT_ALLOWED" , MISSING_BASE_PERMISSIONS : 5 , [ 5 ] : "MISSING_BASE_PERMISSIONS" , CHANNEL_DENIED : 6 , [ 6 ] : "CHANNEL_DENIED" , USER_DENIED : 7 , [ 7 ] : "USER_DENIED" } ;
const result = require ( "TRUE_OPTION_NAME" ) . fileFinishedImporting ( "modules/application_commands/CommandPermissionUtils.tsx" ) ;
2026-07-20 16:05:17 +00:00
export const HasAccessResult = obj ;
export const hasAccess = function hasAccess ( type , arg1 , applicationAllowedForChannel ) {
let allowNsfw ;
let applicationAllowedForUser ;
let commandBotId ;
let commandTypes ;
let computedPermissions ;
let context ;
let hasBaseAccessPermissions ;
let hasSendMessagesPermission ;
let isGuildInstalled ;
let isImpersonating ;
let isUserInstalled ;
let roleIds ;
let userId ;
( { context , commandTypes , computedPermissions , userId , roleIds , isImpersonating } = arg1 ) ;
applicationAllowedForChannel = applicationAllowedForChannel . applicationAllowedForChannel ;
( { allowNsfw , hasBaseAccessPermissions , hasSendMessagesPermission } = arg1 ) ;
( { applicationAllowedForUser , isGuildInstalled , isUserInstalled , commandBotId } = applicationAllowedForChannel ) ;
if ( commandTypes . includes ( type . type ) ) {
if ( type . nsfw ) {
if ( ! allowNsfw ) {
return obj . NSFW_NOT_ALLOWED ;
}
}
if ( null != context ) {
2026-07-24 07:16:23 +00:00
obj = require ( 8012 ) /* computeAllowNsfw */ ;
2026-07-20 16:05:17 +00:00
const commandContextType = obj . computeCommandContextType ( context , commandBotId ) ;
}
if ( null != type . contexts ) {
if ( null != commandContextType ) {
const contexts = type . contexts ;
if ( ! contexts . includes ( commandContextType ) ) {
return obj . CONTEXT_NOT_ALLOWED ;
}
}
2026-07-23 10:11:24 +00:00
} else if ( type . inputType === require ( 6755 ) /* ApplicationCommandSectionType */ . ApplicationCommandInputType . BOT ) {
2026-07-20 16:05:17 +00:00
if ( false === type . dmPermission ) {
2026-07-23 10:11:24 +00:00
if ( commandContextType === require ( 1881 ) /* PermissionOverwriteType */ . InteractionContextType . BOT_DM ) {
2026-07-20 16:05:17 +00:00
return obj . CONTEXT_NOT_ALLOWED ;
}
}
2026-07-23 10:11:24 +00:00
if ( commandContextType === require ( 1881 ) /* PermissionOverwriteType */ . InteractionContextType . PRIVATE_CHANNEL ) {
2026-07-20 16:05:17 +00:00
return obj . CONTEXT_NOT_ALLOWED ;
}
}
if ( null != type . predicate ) {
if ( context instanceof ChannelRecordBase ) {
obj = { channel : context , guild : guild.getGuild ( context . guild_id ) } ;
if ( ! type . predicate ( obj ) ) {
return obj . PREDICATE_FAILED ;
}
}
}
if ( type . applicationId === BuiltInSectionId . BUILT_IN ) {
return obj . ALLOWED ;
} else {
let contextGuildId ;
if ( null != context ) {
2026-07-24 07:16:23 +00:00
contextGuildId = require ( 8012 ) /* computeAllowNsfw */ . getContextGuildId ( context ) ;
const obj3 = require ( 8012 ) /* computeAllowNsfw */ ;
2026-07-20 16:05:17 +00:00
}
if ( null == contextGuildId ) {
return obj . ALLOWED ;
} else {
if ( obj6 . has ( computedPermissions , Permissions . ADMINISTRATOR ) ) {
return obj . ALLOWED ;
} else {
if ( isUserInstalled ) {
const integration_types = type . integration_types ;
if ( null != integration_types ) {
2026-07-24 07:16:23 +00:00
if ( integration_types . includes ( require ( 8224 ) /* ApplicationIntegrationType */ . ApplicationIntegrationType . USER_INSTALL ) ) {
2026-07-20 16:05:17 +00:00
return obj . ALLOWED ;
}
}
}
if ( ! hasBaseAccessPermissions ) {
if ( isGuildInstalled ) {
if ( null != type . integration_types ) {
const integration_types2 = type . integration_types ;
}
return obj . MISSING_BASE_PERMISSIONS ;
}
}
if ( context instanceof ChannelRecordBase ) {
2026-07-23 10:11:24 +00:00
importDefault ( 44 ) ( undefined !== applicationAllowedForChannel , "missing applicationAllowedForChannel" ) ;
2026-07-20 16:05:17 +00:00
const tmp33 = computeAllowedForChannel ( type . permissions , context , contextGuildId ) ;
if ( isExplicitDeny ( tmp33 ) ) {
return obj . CHANNEL_DENIED ;
} else if ( ! isExplicitAllow ( tmp33 ) ) {
if ( isExplicitDeny ( applicationAllowedForChannel ) ) {
return obj . CHANNEL_DENIED ;
}
}
}
const tmp43 = computeAllowedForUser ( type . permissions , contextGuildId , userId , roleIds , isImpersonating ) ;
if ( isExplicitAllow ( tmp43 ) ) {
let USER_DENIED = obj . ALLOWED ;
} else {
if ( ! isExplicitDeny ( tmp43 ) ) {
if ( ! isExplicitDeny ( applicationAllowedForUser ) ) {
if ( null != type . defaultMemberPermissions ) {
2026-07-23 10:11:24 +00:00
if ( ! obj4 . equals ( type . defaultMemberPermissions , require ( 6753 ) /* _createForOfIteratorHelperLoose */ . DISABLED_BY_DEFAULT_PERMISSION_FLAG ) ) {
2026-07-20 16:05:17 +00:00
if ( obj5 . has ( computedPermissions , type . defaultMemberPermissions ) ) {
let USER_DENIED2 = obj . ALLOWED ;
}
2026-07-23 10:11:24 +00:00
obj5 = importAll ( 483 ) ;
2026-07-20 16:05:17 +00:00
}
USER_DENIED2 = obj . USER_DENIED ;
2026-07-23 10:11:24 +00:00
obj4 = importAll ( 483 ) ;
2026-07-20 16:05:17 +00:00
} else {
USER_DENIED = obj . ALLOWED ;
}
}
}
USER_DENIED = obj . USER_DENIED ;
}
return USER_DENIED ;
}
2026-07-23 10:11:24 +00:00
obj6 = importAll ( 483 ) ;
2026-07-20 16:05:17 +00:00
}
}
} else {
return obj . WRONG_COMMAND_TYPE ;
}
} ;
export { computeAllowedForChannel } ;
export { computeAllowedForUser } ;