2026-09-10 05:38:07 +00:00
// Module ID: 14499
// Function ID: 14500
// Name: channels
// Dependencies: [1961, 1957, 1979, 4212, 2011, 4593, 4479, 1074, 8367, 9586, 9591, 12, 14496, 9589, 14490, 5425, 4719, 1100, 8406, 2]
2026-07-23 10:11:24 +00:00
2026-09-10 05:38:07 +00:00
// Module 14499 (channels)
import _modDef12 from "module_12" /* 12 */ ;
import router_utils from "router_utils" /* 1100 */ ;
import ChannelUtils from "ChannelUtils" /* 4719 */ ;
import SelectedChannelActionCreatorsDefault from "SelectedChannelActionCreators" /* 5425 */ ;
import OAuth2Scopes from "OAuth2Scopes" /* 8367 */ ;
import InstantInviteActionCreatorsDefault from "InstantInviteActionCreators" /* 8406 */ ;
import RPCErrorDefault from "RPCError" /* 9586 */ ;
import createRpcJoiSchemaObjectDefault from "createRpcJoiSchemaObject" /* 9589 */ ;
import RPCHelpers from "RPCHelpers" /* 9591 */ ;
import getCurrentEmbeddedActivityChannelDefault from "getCurrentEmbeddedActivityChannel" /* 14496 */ ;
import ChannelRecord from "ChannelRecord" /* 1961 */ ;
import ChannelStore from "ChannelStore" /* 1957 */ ;
import GuildStore from "GuildStore" /* 1979 */ ;
import PermissionStore from "PermissionStore" /* 4212 */ ;
import SelectedChannelStore from "SelectedChannelStore" /* 2011 */ ;
import VoiceStateStore from "VoiceStateStore" /* 4593 */ ;
import Constants_mod from "Constants" /* 4479 */ ;
import Constants_mod from "Constants" /* 1074 */ ;
import size from "module_2" /* 2 */ ;
2026-07-20 16:05:17 +00:00
2026-09-10 05:38:07 +00:00
( { isVoiceChannel : c3 , isTextChannel : closure_4 } = ChannelRecord ) ;
let Constants = Constants_mod ;
( { RPC_SCOPE_CONFIG , RPC_EMBEDDED_APP_SCOPE } = Constants ) ;
let Constants = Constants_mod ;
( { Routes : c10 , Permissions : closure_11 , RPCCommands , RPCErrors : closure_12 } = Constants ) ;
2026-07-20 16:05:17 +00:00
let obj = { } ;
2026-09-10 05:38:07 +00:00
let obj2 = { scope : null , handler : null } ;
let obj3 = { } ;
let items = [ OAuth2Scopes . OAuth2Scopes . RPC , OAuth2Scopes . OAuth2Scopes . GUILDS , OAuth2Scopes . OAuth2Scopes . GUILDS_CHANNELS_READ ] ;
obj3 [ RPC_SCOPE_CONFIG . ANY ] = items ;
obj2 . scope = obj3 ;
obj2 . handler = function handler ( args ) {
2026-07-20 16:05:17 +00:00
const channel_id = args . args . channel_id ;
const socket = args . socket ;
2026-09-10 05:38:07 +00:00
const channel = ChannelStore . getChannel ( channel_id ) ;
2026-07-20 16:05:17 +00:00
if ( null == channel ) {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp142 = new RPCErrorDefault ( obj , "Invalid channel id: " + channel_id ) ;
throw tmp142 ;
2026-07-20 16:05:17 +00:00
} else {
if ( channel . isPrivate ( ) ) {
const scopes = socket . authorization . scopes ;
2026-09-10 05:38:07 +00:00
if ( ! scopes . includes ( OAuth2Scopes . OAuth2Scopes . RPC ) ) {
if ( ! scopes . includes ( tmp ( 8367 ) . OAuth2Scopes . DM_CHANNELS_READ ) ) {
const obj2 = { errorCode : constants2.INVALID_PERMISSIONS } ;
const tmp8 = new RPCErrorDefault ( obj2 , "Invalid scope" ) ;
2026-07-29 08:29:29 +00:00
throw tmp8 ;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
tmp = require ;
2026-07-20 16:05:17 +00:00
}
2026-09-10 05:38:07 +00:00
const obj3 = RPCHelpers ;
return obj3 . transformChannel ( channel , RPCHelpers . hasMessageReadPermission ( channel , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
}
} ;
2026-09-10 05:38:07 +00:00
obj [ RPCCommands . GET_CHANNEL ] = obj2 ;
2026-07-20 16:05:17 +00:00
obj [ RPCCommands . GET_CHANNELS ] = {
2026-09-10 05:38:07 +00:00
scope : OAuth2Scopes.OAuth2Scopes.RPC ,
2026-07-20 16:05:17 +00:00
handler ( args ) {
const guild_id = args . args . guild_id ;
2026-07-23 10:11:24 +00:00
let guild ;
2026-09-10 05:38:07 +00:00
const values = _modDef12 . values ( ChannelStore . loadAllGuildAndPrivateChannelsFromDisk ( ) ) ;
2026-07-20 16:05:17 +00:00
let found = values ;
if ( guild_id ) {
2026-09-10 05:38:07 +00:00
guild = GuildStore . getGuild ( guild_id ) ;
2026-07-20 16:05:17 +00:00
if ( null == guild ) {
2026-09-10 05:38:07 +00:00
const obj2 = { errorCode : constants2.INVALID_GUILD } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmpResult1 = new RPCErrorDefault ( obj2 , "Invalid guild id: " + guild_id ) ;
throw tmpResult1 ;
2026-07-20 16:05:17 +00:00
} else {
found = values . filter ( ( guild_id ) = > guild_id . guild_id === guild . id ) ;
}
}
2026-09-10 05:38:07 +00:00
const obj3 = { channels : null } ;
const found1 = found . filter ( ( item ) = > PermissionStore . can ( constants . VIEW_CHANNEL , item ) ) ;
obj3 . channels = found1 . map ( ( id ) = > ( { id : id.id , name : id.name , type : id . type } ) ) ;
return obj3 ;
2026-07-20 16:05:17 +00:00
}
} ;
2026-09-10 05:38:07 +00:00
let obj5 = { scope : null , handler : null } ;
const obj6 = { } ;
const items1 = [ OAuth2Scopes . OAuth2Scopes . GUILDS_MEMBERS_READ , OAuth2Scopes . OAuth2Scopes . GUILDS_CHANNELS_READ ] ;
obj6 [ RPC_SCOPE_CONFIG . ANY ] = items1 ;
obj5 . scope = obj6 ;
obj5 . handler = function handler() {
2026-08-24 06:08:38 +00:00
const tmp3 = getCurrentEmbeddedActivityChannelDefault ( ) ;
2026-07-29 08:29:29 +00:00
if ( null == tmp3 ) {
2026-09-10 05:38:07 +00:00
const obj2 = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp9 = new RPCErrorDefault ( obj2 , "Invalid channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp9 ;
2026-07-20 16:05:17 +00:00
} else {
2026-09-10 05:38:07 +00:00
const obj = { permissions : PermissionStore.computePermissions ( tmp3 ) } ;
2026-07-20 16:05:17 +00:00
return obj ;
}
} ;
2026-09-10 05:38:07 +00:00
obj [ RPCCommands . GET_CHANNEL_PERMISSIONS ] = obj5 ;
const obj7 = { scope : null , validation : null , handler : null } ;
const obj8 = { } ;
const items2 = [ OAuth2Scopes . OAuth2Scopes . RPC , RPC_EMBEDDED_APP_SCOPE ] ;
obj8 [ RPC_SCOPE_CONFIG . ANY ] = items2 ;
obj7 . scope = obj8 ;
obj7 . validation = function validation ( string ) {
const obj = createRpcJoiSchemaObjectDefault ( string ) ;
const obj2 = { channel_id : null , timeout : null , force : null , navigate : null } ;
const requiredResult = createRpcJoiSchemaObjectDefault ( string ) . required ( ) ;
obj2 . channel_id = string . string ( ) . allow ( null ) ;
2026-08-24 06:08:38 +00:00
const stringResult = string . string ( ) ;
const numberResult = string . number ( ) ;
2026-09-10 05:38:07 +00:00
obj2 . timeout = string . number ( ) . min ( 0 ) . max ( 60 ) ;
obj2 . force = string . boolean ( ) ;
obj2 . navigate = string . boolean ( ) ;
return requiredResult . keys ( obj2 ) ;
2026-07-20 16:05:17 +00:00
} ;
2026-09-10 05:38:07 +00:00
obj7 . handler = function handler ( args ) {
2026-08-24 06:08:38 +00:00
( { server , socket } = args ) ;
args = args . args ;
const channel_id = args . channel_id ;
let num = args . timeout ;
if ( num === undefined ) {
num = 0 ;
}
let flag = args . force ;
if ( flag === undefined ) {
flag = false ;
}
let flag2 = args . navigate ;
if ( flag2 === undefined ) {
flag2 = false ;
}
const scopes = socket . authorization . scopes ;
if ( ! scopes . includes ( socket ( flag2 [ 8 ] ) . OAuth2Scopes . RPC ) ) {
channel_id ( tmp [ 14 ] ) ( socket ) ;
}
if ( channel_id ) {
2026-09-10 05:38:07 +00:00
const voiceChannelId = SelectedChannelStore . getVoiceChannelId ( ) ;
2026-08-24 06:08:38 +00:00
if ( null != voiceChannelId ) {
if ( voiceChannelId !== channel_id ) {
if ( false === flag ) {
2026-09-10 05:38:07 +00:00
let obj2 = { errorCode : constants2.SELECT_VOICE_FORCE_REQUIRED } ;
let tmp15 = new channel_id ( tmp [ 9 ] ) ( obj2 , "User is already joined to a voice channel." ) ;
2026-08-24 06:08:38 +00:00
throw tmp15 ;
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
}
2026-09-10 05:38:07 +00:00
const storeWaitResult = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) ;
const catchPromise = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
2026-08-24 06:08:38 +00:00
throw new channel_id ( flag2 [ 9 ] ) ( { errorCode : constants.SELECT_CHANNEL_TIMED_OUT } , "Request to select voice channel timed out." ) ;
} ) ;
2026-09-10 05:38:07 +00:00
return server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
2026-08-24 06:08:38 +00:00
throw new channel_id ( flag2 [ 9 ] ) ( { errorCode : constants.SELECT_CHANNEL_TIMED_OUT } , "Request to select voice channel timed out." ) ;
} ) . then ( ( type ) = > {
if ( null == type ) {
2026-09-10 05:38:07 +00:00
const obj4 = { errorCode : constants2.INVALID_CHANNEL } ;
2026-08-24 06:08:38 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp162 = new RPCErrorDefault ( obj4 , "Invalid channel id: " + channel_id ) ;
throw tmp162 ;
} else if ( React3 ( type . type ) ) {
2026-08-24 06:08:38 +00:00
const items = [ Promise . resolve ( type ) , ] ;
2026-09-10 05:38:07 +00:00
const obj2 = RPCHelpers ;
items [ 1 ] = obj2 . transformChannel ( type , RPCHelpers . hasMessageReadPermission ( type , socket . application . id , socket . authorization . scopes ) ) ;
2026-08-24 06:08:38 +00:00
return Promise . all ( items ) ;
} else {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp7 = new RPCErrorDefault ( obj , "Channel is not a voice channel" ) ;
2026-08-24 06:08:38 +00:00
throw tmp7 ;
}
2026-09-10 05:38:07 +00:00
} ) . then ( ( result ) = > {
[ tmp , tmp2 ] = result ;
2026-08-24 06:08:38 +00:00
if ( tmp2 . guild_id ) {
2026-09-10 05:38:07 +00:00
if ( obj . isChannelFull ( tmp , VoiceStateStore , GuildStore ) ) {
const obj2 = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp28 = new RPCErrorDefault ( obj2 , "Channel is full" ) ;
2026-08-24 06:08:38 +00:00
throw tmp28 ;
2026-09-10 05:38:07 +00:00
} else if ( ! PermissionStore . can ( constants . CONNECT , tmp ) ) {
const obj5 = { errorCode : constants2.INVALID_PERMISSIONS } ;
const tmp15 = new RPCErrorDefault ( obj5 , "Connect permission required to join channel" ) ;
2026-08-24 06:08:38 +00:00
throw tmp15 ;
2026-07-20 16:05:17 +00:00
}
2026-09-10 05:38:07 +00:00
obj = ChannelUtils ;
2026-08-24 06:08:38 +00:00
}
2026-09-10 05:38:07 +00:00
const voiceChannel = SelectedChannelActionCreatorsDefault . selectVoiceChannel ( tmp . id ) ;
2026-08-24 06:08:38 +00:00
if ( flag2 ) {
2026-09-10 05:38:07 +00:00
router_utils . replaceWith ( closure_2_10 . CHANNEL ( tmp . guild_id , tmp . id ) ) ;
2026-08-24 06:08:38 +00:00
}
return tmp2 ;
} ) ;
} else {
2026-09-10 05:38:07 +00:00
let voiceChannel = channel_id ( tmp [ 15 ] ) . selectVoiceChannel ( null ) ;
2026-08-24 06:08:38 +00:00
return null ;
2026-07-20 16:05:17 +00:00
}
} ;
2026-09-10 05:38:07 +00:00
obj [ RPCCommands . SELECT_VOICE_CHANNEL ] = obj7 ;
const obj9 = { scope : null , handler : null } ;
const obj10 = { } ;
const items3 = [ OAuth2Scopes . OAuth2Scopes . RPC , OAuth2Scopes . OAuth2Scopes . RPC_VOICE_READ ] ;
obj10 [ RPC_SCOPE_CONFIG . ANY ] = items3 ;
obj9 . scope = obj10 ;
obj9 . handler = function handler ( socket ) {
2026-07-20 16:05:17 +00:00
socket = socket . socket ;
2026-09-10 05:38:07 +00:00
const voiceChannelId = SelectedChannelStore . getVoiceChannelId ( ) ;
2026-07-20 16:05:17 +00:00
let channel = null ;
if ( null != voiceChannelId ) {
2026-09-10 05:38:07 +00:00
channel = ChannelStore . getChannel ( voiceChannelId ) ;
2026-07-20 16:05:17 +00:00
}
let transformChannelResult = null ;
if ( null != channel ) {
2026-09-10 05:38:07 +00:00
const obj = RPCHelpers ;
transformChannelResult = obj . transformChannel ( channel , RPCHelpers . hasMessageReadPermission ( channel , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
}
return transformChannelResult ;
} ;
2026-09-10 05:38:07 +00:00
obj [ RPCCommands . GET_SELECTED_VOICE_CHANNEL ] = obj9 ;
let obj4 = {
scope : OAuth2Scopes.OAuth2Scopes.RPC ,
2026-07-20 16:05:17 +00:00
handler ( args ) {
2026-08-24 06:08:38 +00:00
const guild_id = args . args . guild_id ;
let guild ;
2026-09-10 05:38:07 +00:00
const values = _modDef12 . values ( ChannelStore . loadAllGuildAndPrivateChannelsFromDisk ( ) ) ;
2026-08-24 06:08:38 +00:00
let found = values ;
if ( guild_id ) {
2026-09-10 05:38:07 +00:00
guild = GuildStore . getGuild ( guild_id ) ;
2026-08-24 06:08:38 +00:00
if ( null == guild ) {
2026-09-10 05:38:07 +00:00
const obj2 = { errorCode : constants2.INVALID_GUILD } ;
2026-08-24 06:08:38 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmpResult1 = new RPCErrorDefault ( obj2 , "Invalid guild id: " + guild_id ) ;
throw tmpResult1 ;
2026-08-24 06:08:38 +00:00
} else {
found = values . filter ( ( guild_id ) = > guild_id . guild_id === guild . id ) ;
2026-07-20 16:05:17 +00:00
}
}
2026-09-10 05:38:07 +00:00
const obj3 = { channels : null } ;
const found1 = found . filter ( ( item ) = > PermissionStore . can ( constants . VIEW_CHANNEL , item ) ) ;
obj3 . channels = found1 . map ( ( id ) = > ( { id : id.id , name : id.name , type : id . type } ) ) ;
return obj3 ;
2026-07-20 16:05:17 +00:00
}
} ;
obj [ RPCCommands . SELECT_TEXT_CHANNEL ] = {
2026-09-10 05:38:07 +00:00
scope : OAuth2Scopes.OAuth2Scopes.RPC ,
2026-07-20 16:05:17 +00:00
validation ( string ) {
2026-09-10 05:38:07 +00:00
const obj = createRpcJoiSchemaObjectDefault ( string ) ;
const obj2 = { channel_id : null , timeout : null } ;
const requiredResult = createRpcJoiSchemaObjectDefault ( string ) . required ( ) ;
obj2 . channel_id = string . string ( ) . allow ( null ) ;
2026-07-20 16:05:17 +00:00
const stringResult = string . string ( ) ;
const numberResult = string . number ( ) ;
2026-09-10 05:38:07 +00:00
obj2 . timeout = string . number ( ) . min ( 0 ) . max ( 60 ) ;
return requiredResult . keys ( obj2 ) ;
2026-07-20 16:05:17 +00:00
} ,
handler ( args ) {
( { server , socket } = args ) ;
args = args . args ;
const channel_id = args . channel_id ;
let num = args . timeout ;
if ( num === undefined ) {
num = 0 ;
}
if ( channel_id ) {
2026-09-10 05:38:07 +00:00
const storeWaitResult = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) ;
const catchPromise = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) ;
2026-09-10 05:38:07 +00:00
let nextPromise1 = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) . then ( ( type ) = > {
if ( null == type ) {
2026-09-10 05:38:07 +00:00
const obj4 = { errorCode : constants2.INVALID_CHANNEL } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp162 = new RPCErrorDefault ( obj4 , "Invalid channel id: " + channel_id ) ;
throw tmp162 ;
} else if ( React4 ( type . type ) ) {
2026-07-20 16:05:17 +00:00
const items = [ Promise . resolve ( type ) , ] ;
2026-09-10 05:38:07 +00:00
const obj2 = RPCHelpers ;
items [ 1 ] = obj2 . transformChannel ( type , RPCHelpers . hasMessageReadPermission ( type , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
return Promise . all ( items ) ;
} else {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp7 = new RPCErrorDefault ( obj , "Channel is not a text channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp7 ;
2026-07-20 16:05:17 +00:00
}
2026-09-10 05:38:07 +00:00
} ) . then ( ( result ) = > {
[ tmp , tmp2 ] = result ;
2026-07-20 16:05:17 +00:00
if ( tmp2 . guild_id ) {
2026-09-10 05:38:07 +00:00
if ( ! PermissionStore . can ( constants . VIEW_CHANNEL , tmp ) ) {
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp11 = new channel_id ( 9586 ) ( obj , "No permission to see channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp11 ;
2026-07-20 16:05:17 +00:00
}
}
if ( tmp2 . guild_id ) {
2026-09-10 05:38:07 +00:00
socket ( 1100 ) . replaceWith ( closure_1_10 . CHANNEL ( tmp2 . guild_id , tmp . id ) ) ;
2026-09-05 10:56:28 +00:00
const obj3 = socket ( 1100 ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-09-10 05:38:07 +00:00
const privateChannel = channel_id ( 5425 ) . selectPrivateChannel ( tmp . id ) ;
const obj2 = channel_id ( 5425 ) ;
2026-07-20 16:05:17 +00:00
}
return tmp2 ;
} ) ;
2026-09-10 05:38:07 +00:00
const nextPromise = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) . then ( ( type ) = > {
if ( null == type ) {
2026-09-10 05:38:07 +00:00
const obj4 = { errorCode : constants2.INVALID_CHANNEL } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp162 = new RPCErrorDefault ( obj4 , "Invalid channel id: " + channel_id ) ;
throw tmp162 ;
} else if ( React4 ( type . type ) ) {
2026-07-20 16:05:17 +00:00
const items = [ Promise . resolve ( type ) , ] ;
2026-09-10 05:38:07 +00:00
const obj2 = RPCHelpers ;
items [ 1 ] = obj2 . transformChannel ( type , RPCHelpers . hasMessageReadPermission ( type , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
return Promise . all ( items ) ;
} else {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp7 = new RPCErrorDefault ( obj , "Channel is not a text channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp7 ;
2026-07-20 16:05:17 +00:00
}
} ) ;
} else {
2026-09-10 05:38:07 +00:00
socket ( 1100 ) . transitionTo ( closure_10 . ME ) ;
2026-07-20 16:05:17 +00:00
nextPromise1 = null ;
2026-09-05 10:56:28 +00:00
let obj = socket ( 1100 ) ;
2026-07-20 16:05:17 +00:00
}
return nextPromise1 ;
}
} ;
2026-09-10 05:38:07 +00:00
const obj11 = {
scope : OAuth2Scopes.OAuth2Scopes.RPC ,
2026-07-20 16:05:17 +00:00
validation ( string ) {
2026-09-10 05:38:07 +00:00
const obj = createRpcJoiSchemaObjectDefault ( string ) ;
const obj2 = { channel_id : null , timeout : null } ;
const requiredResult = createRpcJoiSchemaObjectDefault ( string ) . required ( ) ;
obj2 . channel_id = string . string ( ) . allow ( null ) ;
2026-07-20 16:05:17 +00:00
const stringResult = string . string ( ) ;
const numberResult = string . number ( ) ;
2026-09-10 05:38:07 +00:00
obj2 . timeout = string . number ( ) . min ( 0 ) . max ( 60 ) ;
return requiredResult . keys ( obj2 ) ;
2026-07-20 16:05:17 +00:00
} ,
handler ( args ) {
( { server , socket } = args ) ;
args = args . args ;
const channel_id = args . channel_id ;
let num = args . timeout ;
if ( num === undefined ) {
num = 0 ;
}
if ( channel_id ) {
2026-09-10 05:38:07 +00:00
const storeWaitResult = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) ;
const catchPromise = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) ;
2026-09-10 05:38:07 +00:00
let nextPromise1 = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) . then ( ( type ) = > {
if ( null == type ) {
2026-09-10 05:38:07 +00:00
const obj4 = { errorCode : constants2.INVALID_CHANNEL } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp162 = new RPCErrorDefault ( obj4 , "Invalid channel id: " + channel_id ) ;
throw tmp162 ;
} else if ( React4 ( type . type ) ) {
2026-07-20 16:05:17 +00:00
const items = [ Promise . resolve ( type ) , ] ;
2026-09-10 05:38:07 +00:00
const obj2 = RPCHelpers ;
items [ 1 ] = obj2 . transformChannel ( type , RPCHelpers . hasMessageReadPermission ( type , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
return Promise . all ( items ) ;
} else {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp7 = new RPCErrorDefault ( obj , "Channel is not a text channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp7 ;
2026-07-20 16:05:17 +00:00
}
2026-09-10 05:38:07 +00:00
} ) . then ( ( result ) = > {
[ tmp , tmp2 ] = result ;
2026-07-20 16:05:17 +00:00
if ( tmp2 . guild_id ) {
2026-09-10 05:38:07 +00:00
if ( ! PermissionStore . can ( constants . VIEW_CHANNEL , tmp ) ) {
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp11 = new channel_id ( 9586 ) ( obj , "No permission to see channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp11 ;
2026-07-20 16:05:17 +00:00
}
}
if ( tmp2 . guild_id ) {
2026-09-10 05:38:07 +00:00
socket ( 1100 ) . replaceWith ( closure_1_10 . CHANNEL ( tmp2 . guild_id , tmp . id ) ) ;
2026-09-05 10:56:28 +00:00
const obj3 = socket ( 1100 ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-09-10 05:38:07 +00:00
const privateChannel = channel_id ( 5425 ) . selectPrivateChannel ( tmp . id ) ;
const obj2 = channel_id ( 5425 ) ;
2026-07-20 16:05:17 +00:00
}
return tmp2 ;
} ) ;
2026-09-10 05:38:07 +00:00
const nextPromise = server . storeWait ( socket , ( ) = > ChannelStore . getChannel ( channel_id ) , num ) . catch ( ( ) = > {
throw new channel_id ( 9586 ) ( { errorCode : constants2.SELECT_CHANNEL_TIMED_OUT } , "Request to select text channel timed out." ) ;
2026-07-20 16:05:17 +00:00
} ) . then ( ( type ) = > {
if ( null == type ) {
2026-09-10 05:38:07 +00:00
const obj4 = { errorCode : constants2.INVALID_CHANNEL } ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-09-10 05:38:07 +00:00
const tmp162 = new RPCErrorDefault ( obj4 , "Invalid channel id: " + channel_id ) ;
throw tmp162 ;
} else if ( React4 ( type . type ) ) {
2026-07-20 16:05:17 +00:00
const items = [ Promise . resolve ( type ) , ] ;
2026-09-10 05:38:07 +00:00
const obj2 = RPCHelpers ;
items [ 1 ] = obj2 . transformChannel ( type , RPCHelpers . hasMessageReadPermission ( type , socket . application . id , socket . authorization . scopes ) ) ;
2026-07-20 16:05:17 +00:00
return Promise . all ( items ) ;
} else {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_CHANNEL } ;
const tmp7 = new RPCErrorDefault ( obj , "Channel is not a text channel" ) ;
2026-07-29 08:29:29 +00:00
throw tmp7 ;
2026-07-20 16:05:17 +00:00
}
} ) ;
} else {
2026-09-10 05:38:07 +00:00
socket ( 1100 ) . transitionTo ( closure_10 . ME ) ;
2026-07-20 16:05:17 +00:00
nextPromise1 = null ;
2026-09-05 10:56:28 +00:00
let obj = socket ( 1100 ) ;
2026-07-20 16:05:17 +00:00
}
return nextPromise1 ;
}
} ;
obj [ RPCCommands . CREATE_CHANNEL_INVITE ] = {
2026-09-10 05:38:07 +00:00
scope : OAuth2Scopes.OAuth2Scopes.RPC ,
2026-07-20 16:05:17 +00:00
handler ( args ) {
args = args . args ;
const channel_id = args . channel_id ;
2026-09-10 05:38:07 +00:00
const merged = Object . assign ( args , Object . assign ( { channel_id : 0 } ) ) ;
const invite = InstantInviteActionCreatorsDefault . createInvite ( channel_id , merged , "RPC" ) ;
2026-07-20 16:05:17 +00:00
return invite . catch ( ( ) = > {
2026-09-10 05:38:07 +00:00
const obj = { errorCode : constants2.INVALID_PERMISSIONS } ;
throw new RPCErrorDefault ( { errorCode : constants2.INVALID_PERMISSIONS } , "Unable to generate an invite for " + channel_id + ". Does this user have permissions?" ) ;
2026-07-20 16:05:17 +00:00
} ) ;
}
} ;
2026-09-10 05:38:07 +00:00
const result = size . fileFinishedImporting ( "modules/rpc/server/commands/channels.tsx" ) ;
2026-07-20 16:05:17 +00:00
export default obj ;