decord/source/modules/rpc/server/commands/channels.tsx

585 lines
23 KiB
TypeScript
Raw Normal View History

2026-08-08 06:10:11 +00:00
// Module ID: 13738
// Function ID: 13739
2026-07-20 16:05:17 +00:00
// Name: items
2026-08-08 06:10:11 +00:00
// Dependencies: [1376, 1372, 1891, 3929, 1960, 4319, 4206, 676, 8902, 10736, 10741, 12, 13735, 10739, 5129, 4486, 1222, 7758, 2]
2026-07-23 10:11:24 +00:00
2026-08-08 06:10:11 +00:00
// Module 13738 (items)
2026-07-29 08:29:29 +00:00
import createChannelRecord from "createChannelRecord";
import ensureGuildLoaded from "ensureGuildLoaded";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import getUncachedChannelPermissions from "getUncachedChannelPermissions";
import handleConnectionOpen from "handleConnectionOpen";
import updateVoiceState from "updateVoiceState";
2026-07-23 10:11:24 +00:00
import { RPC_SCOPE_CONFIG } from "RPC_SCOPE_CONFIG";
import ME from "ME";
2026-07-20 16:05:17 +00:00
let RPCCommands;
2026-07-29 08:29:29 +00:00
let c10;
let c3;
let c4;
2026-07-23 10:11:24 +00:00
let closure_12;
2026-07-29 08:29:29 +00:00
let unpackModuleId;
({ isVoiceChannel: c3, isTextChannel: c4 } = createChannelRecord);
({ Routes: c10, Permissions: unpackModuleId, RPCCommands, RPCErrors: closure_12 } = ME);
2026-07-20 16:05:17 +00:00
let obj = {};
2026-07-29 08:29:29 +00:00
obj = { scope: null, handler: null };
2026-07-20 16:05:17 +00:00
obj = {};
2026-07-23 10:11:24 +00:00
let items = [require("set").OAuth2Scopes.RPC, require("set").OAuth2Scopes.GUILDS, require("set").OAuth2Scopes.GUILDS_CHANNELS_READ];
2026-07-20 16:05:17 +00:00
obj[RPC_SCOPE_CONFIG.ANY] = items;
2026-07-29 08:29:29 +00:00
obj[0] = obj;
obj[1] = function handler(args) {
2026-07-20 16:05:17 +00:00
const channel_id = args.args.channel_id;
const socket = args.socket;
const channel = store.getChannel(channel_id);
if (null == channel) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = constants2.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-08-08 06:10:11 +00:00
let tmp14 = importDefault(10736);
2026-07-29 08:29:29 +00:00
tmp14 = new tmp14(obj, "Invalid channel id: " + channel_id);
throw tmp14;
2026-07-20 16:05:17 +00:00
} else {
if (channel.isPrivate()) {
const scopes = socket.authorization.scopes;
2026-08-08 06:10:11 +00:00
if (!scopes.includes(require(8902) /* set */.OAuth2Scopes.RPC)) {
if (!scopes.includes(tmp(8902).OAuth2Scopes.DM_CHANNELS_READ)) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = constants2.INVALID_PERMISSIONS;
2026-08-08 06:10:11 +00:00
const tmp8 = new importDefault(10736)(obj, "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-08-08 06:10:11 +00:00
const obj3 = require(10741) /* recurseReplaceContentTree */;
return obj3.transformChannel(channel, require(10741) /* recurseReplaceContentTree */.hasMessageReadPermission(channel, socket.application.id, socket.authorization.scopes));
2026-07-20 16:05:17 +00:00
}
};
obj[RPCCommands.GET_CHANNEL] = obj;
obj[RPCCommands.GET_CHANNELS] = {
2026-07-23 10:11:24 +00:00
scope: require("set").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-07-29 08:29:29 +00:00
let obj = importDefault(12);
2026-07-20 16:05:17 +00:00
const values = obj.values(store.loadAllGuildAndPrivateChannelsFromDisk());
let found = values;
if (guild_id) {
2026-07-23 10:11:24 +00:00
guild = guild.getGuild(guild_id);
2026-07-20 16:05:17 +00:00
if (null == guild) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = constants2.INVALID_GUILD;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-08-08 06:10:11 +00:00
let tmpResult = importDefault(10736);
2026-07-29 08:29:29 +00:00
tmpResult = new tmpResult(obj, "Invalid guild id: " + guild_id);
throw tmpResult;
2026-07-20 16:05:17 +00:00
} else {
found = values.filter((guild_id) => guild_id.guild_id === guild.id);
}
}
2026-07-29 08:29:29 +00:00
obj = { channels: null };
const found1 = found.filter((arg0) => getUncachedChannelPermissions.can(constants.VIEW_CHANNEL, arg0));
obj[0] = found1.map((id) => ({ id: id.id, name: id.name, type: id.type }));
2026-07-20 16:05:17 +00:00
return obj;
}
};
2026-07-29 08:29:29 +00:00
let obj2 = { scope: null, handler: null };
2026-07-23 10:11:24 +00:00
let obj3 = {};
const items1 = [require("set").OAuth2Scopes.GUILDS_MEMBERS_READ, require("set").OAuth2Scopes.GUILDS_CHANNELS_READ];
2026-07-20 16:05:17 +00:00
obj3[RPC_SCOPE_CONFIG.ANY] = items1;
2026-07-29 08:29:29 +00:00
obj2[0] = obj3;
obj2[1] = function handler() {
2026-08-08 06:10:11 +00:00
const tmp3 = importDefault(13735)();
2026-07-29 08:29:29 +00:00
if (null == tmp3) {
let obj = { errorCode: null };
obj[0] = constants2.INVALID_CHANNEL;
2026-08-08 06:10:11 +00:00
const tmp9 = new tmp(10736)(obj, "Invalid channel");
2026-07-29 08:29:29 +00:00
throw tmp9;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
obj = { permissions: null };
obj[0] = getUncachedChannelPermissions.computePermissions(tmp3);
2026-07-20 16:05:17 +00:00
return obj;
}
2026-07-29 08:29:29 +00:00
tmp = importDefault;
2026-07-20 16:05:17 +00:00
};
obj[RPCCommands.GET_CHANNEL_PERMISSIONS] = obj2;
const obj1 = {
2026-07-23 10:11:24 +00:00
scope: require("set").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-07-29 08:29:29 +00:00
let obj = importDefault(12);
2026-07-20 16:05:17 +00:00
const values = obj.values(store.loadAllGuildAndPrivateChannelsFromDisk());
let found = values;
if (guild_id) {
2026-07-23 10:11:24 +00:00
guild = guild.getGuild(guild_id);
2026-07-20 16:05:17 +00:00
if (null == guild) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = constants2.INVALID_GUILD;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-08-08 06:10:11 +00:00
let tmpResult = importDefault(10736);
2026-07-29 08:29:29 +00:00
tmpResult = new tmpResult(obj, "Invalid guild id: " + guild_id);
throw tmpResult;
2026-07-20 16:05:17 +00:00
} else {
found = values.filter((guild_id) => guild_id.guild_id === guild.id);
}
}
2026-07-29 08:29:29 +00:00
obj = { channels: null };
const found1 = found.filter((arg0) => getUncachedChannelPermissions.can(constants.VIEW_CHANNEL, arg0));
obj[0] = found1.map((id) => ({ id: id.id, name: id.name, type: id.type }));
2026-07-20 16:05:17 +00:00
return obj;
}
};
obj[RPCCommands.SELECT_VOICE_CHANNEL] = {
2026-07-23 10:11:24 +00:00
scope: require("set").OAuth2Scopes.RPC,
2026-07-20 16:05:17 +00:00
validation(string) {
2026-08-08 06:10:11 +00:00
let obj = importDefault(10739)(string);
2026-07-29 08:29:29 +00:00
obj = { channel_id: null, timeout: null, force: null, navigate: null };
2026-07-20 16:05:17 +00:00
const requiredResult = obj.required();
2026-07-29 08:29:29 +00:00
obj[0] = string.string().allow(null);
2026-07-20 16:05:17 +00:00
const stringResult = string.string();
const numberResult = string.number();
2026-07-29 08:29:29 +00:00
obj[1] = string.number().min(0).max(60);
obj[2] = string.boolean();
obj[3] = string.boolean();
2026-07-20 16:05:17 +00:00
return requiredResult.keys(obj);
},
handler(args) {
let server;
let socket;
({ 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;
}
if (channel_id) {
const voiceChannelId = store2.getVoiceChannelId();
if (null != voiceChannelId) {
if (voiceChannelId !== channel_id) {
if (false === flag) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = constants2.SELECT_VOICE_FORCE_REQUIRED;
const tmp14 = new channel_id(flag2[9])(obj, "User is already joined to a voice channel.");
throw tmp14;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-23 10:11:24 +00:00
const storeWaitResult = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num);
const catchPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-07-29 08:29:29 +00:00
throw new channel_id(flag2[9])({ errorCode: constants.SELECT_CHANNEL_TIMED_OUT }, "Request to select voice channel timed out.");
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
return server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-07-29 08:29:29 +00:00
throw new channel_id(flag2[9])({ errorCode: constants.SELECT_CHANNEL_TIMED_OUT }, "Request to select voice channel timed out.");
2026-07-20 16:05:17 +00:00
}).then((type) => {
if (null == type) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(flag2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_3(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
const obj2 = socket(flag2[10]);
items[1] = obj2.transformChannel(type, socket(flag2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(flag2[9])(obj, "Channel is not a voice channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
}).then((arg0) => {
let tmp;
let tmp2;
[tmp, tmp2] = arg0;
if (tmp2.guild_id) {
let obj = socket(flag2[15]);
2026-07-23 10:11:24 +00:00
if (obj.isChannelFull(tmp, outer1_9, outer1_6)) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp28 = new channel_id(flag2[9])(obj, "Channel is full");
throw tmp28;
2026-07-23 10:11:24 +00:00
} else if (!outer1_7.can(outer1_11.CONNECT, tmp)) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_PERMISSIONS;
const tmp15 = new channel_id(flag2[9])(obj, "Connect permission required to join channel");
throw tmp15;
2026-07-20 16:05:17 +00:00
}
}
const voiceChannel = channel_id(flag2[14]).selectVoiceChannel(tmp.id);
if (flag2) {
2026-07-23 10:11:24 +00:00
socket(flag2[16]).replaceWith(outer1_10.CHANNEL(tmp.guild_id, tmp.id));
2026-07-20 16:05:17 +00:00
const obj4 = socket(flag2[16]);
}
return tmp2;
});
} else {
2026-07-23 10:11:24 +00:00
obj = channel_id(flag2[14]);
let voiceChannel = obj.selectVoiceChannel(null);
2026-07-20 16:05:17 +00:00
return null;
}
}
};
2026-07-29 08:29:29 +00:00
const obj5 = { scope: null, handler: null };
2026-07-20 16:05:17 +00:00
const obj6 = {};
2026-07-23 10:11:24 +00:00
const items2 = [require("set").OAuth2Scopes.RPC, require("set").OAuth2Scopes.RPC_VOICE_READ];
2026-07-20 16:05:17 +00:00
obj6[RPC_SCOPE_CONFIG.ANY] = items2;
2026-07-29 08:29:29 +00:00
obj5[0] = obj6;
obj5[1] = function handler(socket) {
2026-07-20 16:05:17 +00:00
socket = socket.socket;
const voiceChannelId = store2.getVoiceChannelId();
let channel = null;
if (null != voiceChannelId) {
channel = store.getChannel(voiceChannelId);
}
let transformChannelResult = null;
if (null != channel) {
2026-08-08 06:10:11 +00:00
const obj = require(10741) /* recurseReplaceContentTree */;
transformChannelResult = obj.transformChannel(channel, require(10741) /* recurseReplaceContentTree */.hasMessageReadPermission(channel, socket.application.id, socket.authorization.scopes));
const obj2 = require(10741) /* recurseReplaceContentTree */;
2026-07-20 16:05:17 +00:00
}
return transformChannelResult;
};
obj[RPCCommands.GET_SELECTED_VOICE_CHANNEL] = obj5;
2026-07-23 10:11:24 +00:00
let obj4 = {
scope: require("set").OAuth2Scopes.RPC,
2026-07-20 16:05:17 +00:00
validation(string) {
2026-08-08 06:10:11 +00:00
let obj = importDefault(10739)(string);
2026-07-29 08:29:29 +00:00
obj = { channel_id: null, timeout: null, force: null, navigate: null };
2026-07-20 16:05:17 +00:00
const requiredResult = obj.required();
2026-07-29 08:29:29 +00:00
obj[0] = string.string().allow(null);
2026-07-20 16:05:17 +00:00
const stringResult = string.string();
const numberResult = string.number();
2026-07-29 08:29:29 +00:00
obj[1] = string.number().min(0).max(60);
obj[2] = string.boolean();
obj[3] = string.boolean();
2026-07-20 16:05:17 +00:00
return requiredResult.keys(obj);
},
handler(args) {
let server;
let socket;
({ 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;
}
if (channel_id) {
const voiceChannelId = store2.getVoiceChannelId();
if (null != voiceChannelId) {
if (voiceChannelId !== channel_id) {
if (false === flag) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = constants2.SELECT_VOICE_FORCE_REQUIRED;
const tmp14 = new channel_id(flag2[9])(obj, "User is already joined to a voice channel.");
throw tmp14;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-23 10:11:24 +00:00
const storeWaitResult = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num);
const catchPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-07-29 08:29:29 +00:00
throw new channel_id(flag2[9])({ errorCode: constants.SELECT_CHANNEL_TIMED_OUT }, "Request to select voice channel timed out.");
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
return server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-07-29 08:29:29 +00:00
throw new channel_id(flag2[9])({ errorCode: constants.SELECT_CHANNEL_TIMED_OUT }, "Request to select voice channel timed out.");
2026-07-20 16:05:17 +00:00
}).then((type) => {
if (null == type) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(flag2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_3(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
const obj2 = socket(flag2[10]);
items[1] = obj2.transformChannel(type, socket(flag2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(flag2[9])(obj, "Channel is not a voice channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
}).then((arg0) => {
let tmp;
let tmp2;
[tmp, tmp2] = arg0;
if (tmp2.guild_id) {
let obj = socket(flag2[15]);
2026-07-23 10:11:24 +00:00
if (obj.isChannelFull(tmp, outer1_9, outer1_6)) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp28 = new channel_id(flag2[9])(obj, "Channel is full");
throw tmp28;
2026-07-23 10:11:24 +00:00
} else if (!outer1_7.can(outer1_11.CONNECT, tmp)) {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_PERMISSIONS;
const tmp15 = new channel_id(flag2[9])(obj, "Connect permission required to join channel");
throw tmp15;
2026-07-20 16:05:17 +00:00
}
}
const voiceChannel = channel_id(flag2[14]).selectVoiceChannel(tmp.id);
if (flag2) {
2026-07-23 10:11:24 +00:00
socket(flag2[16]).replaceWith(outer1_10.CHANNEL(tmp.guild_id, tmp.id));
2026-07-20 16:05:17 +00:00
const obj4 = socket(flag2[16]);
}
return tmp2;
});
} else {
2026-07-23 10:11:24 +00:00
obj = channel_id(flag2[14]);
let voiceChannel = obj.selectVoiceChannel(null);
2026-07-20 16:05:17 +00:00
return null;
}
}
};
obj[RPCCommands.SELECT_TEXT_CHANNEL] = {
2026-07-23 10:11:24 +00:00
scope: require("set").OAuth2Scopes.RPC,
2026-07-20 16:05:17 +00:00
validation(string) {
2026-08-08 06:10:11 +00:00
let obj = importDefault(10739)(string);
2026-07-29 08:29:29 +00:00
obj = { channel_id: null, timeout: null };
2026-07-20 16:05:17 +00:00
const requiredResult = obj.required();
2026-07-29 08:29:29 +00:00
obj[0] = string.string().allow(null);
2026-07-20 16:05:17 +00:00
const stringResult = string.string();
const numberResult = string.number();
2026-07-29 08:29:29 +00:00
obj[1] = string.number().min(0).max(60);
2026-07-20 16:05:17 +00:00
return requiredResult.keys(obj);
},
handler(args) {
let server;
let socket;
({ 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-07-23 10:11:24 +00:00
const storeWaitResult = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num);
const catchPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ errorCode: constants2.SELECT_CHANNEL_TIMED_OUT }, "Request to select text channel timed out.");
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
let nextPromise1 = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ 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-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(outer1_2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_4(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
2026-07-23 10:11:24 +00:00
const obj2 = socket(outer1_2[10]);
items[1] = obj2.transformChannel(type, socket(outer1_2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
2026-07-20 16:05:17 +00:00
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(outer1_2[9])(obj, "Channel is not a text channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
}).then((arg0) => {
let tmp;
let tmp2;
[tmp, tmp2] = arg0;
if (tmp2.guild_id) {
2026-07-29 08:29:29 +00:00
if (!getUncachedChannelPermissions.can(constants.VIEW_CHANNEL, tmp)) {
const obj = { errorCode: null };
obj[0] = constants2.INVALID_CHANNEL;
2026-08-08 06:10:11 +00:00
const tmp11 = new channel_id(10736)(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-07-29 08:29:29 +00:00
socket(1222).replaceWith(closure_10.CHANNEL(tmp2.guild_id, tmp.id));
const obj3 = socket(1222);
2026-07-20 16:05:17 +00:00
} else {
2026-08-08 06:10:11 +00:00
const privateChannel = channel_id(5129).selectPrivateChannel(tmp.id);
const obj2 = channel_id(5129);
2026-07-20 16:05:17 +00:00
}
return tmp2;
});
2026-07-23 10:11:24 +00:00
const nextPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ 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-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(outer1_2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_4(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
2026-07-23 10:11:24 +00:00
const obj2 = socket(outer1_2[10]);
items[1] = obj2.transformChannel(type, socket(outer1_2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
2026-07-20 16:05:17 +00:00
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(outer1_2[9])(obj, "Channel is not a text channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
});
} else {
2026-07-29 08:29:29 +00:00
socket(1222).transitionTo(constants.ME);
2026-07-20 16:05:17 +00:00
nextPromise1 = null;
2026-07-29 08:29:29 +00:00
let obj = socket(1222);
2026-07-20 16:05:17 +00:00
}
return nextPromise1;
}
};
const obj7 = {
2026-07-23 10:11:24 +00:00
scope: require("set").OAuth2Scopes.RPC,
2026-07-20 16:05:17 +00:00
validation(string) {
2026-08-08 06:10:11 +00:00
let obj = importDefault(10739)(string);
2026-07-29 08:29:29 +00:00
obj = { channel_id: null, timeout: null };
2026-07-20 16:05:17 +00:00
const requiredResult = obj.required();
2026-07-29 08:29:29 +00:00
obj[0] = string.string().allow(null);
2026-07-20 16:05:17 +00:00
const stringResult = string.string();
const numberResult = string.number();
2026-07-29 08:29:29 +00:00
obj[1] = string.number().min(0).max(60);
2026-07-20 16:05:17 +00:00
return requiredResult.keys(obj);
},
handler(args) {
let server;
let socket;
({ 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-07-23 10:11:24 +00:00
const storeWaitResult = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num);
const catchPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ errorCode: constants2.SELECT_CHANNEL_TIMED_OUT }, "Request to select text channel timed out.");
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
let nextPromise1 = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ 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-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(outer1_2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_4(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
2026-07-23 10:11:24 +00:00
const obj2 = socket(outer1_2[10]);
items[1] = obj2.transformChannel(type, socket(outer1_2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
2026-07-20 16:05:17 +00:00
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(outer1_2[9])(obj, "Channel is not a text channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
}).then((arg0) => {
let tmp;
let tmp2;
[tmp, tmp2] = arg0;
if (tmp2.guild_id) {
2026-07-29 08:29:29 +00:00
if (!getUncachedChannelPermissions.can(constants.VIEW_CHANNEL, tmp)) {
const obj = { errorCode: null };
obj[0] = constants2.INVALID_CHANNEL;
2026-08-08 06:10:11 +00:00
const tmp11 = new channel_id(10736)(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-07-29 08:29:29 +00:00
socket(1222).replaceWith(closure_10.CHANNEL(tmp2.guild_id, tmp.id));
const obj3 = socket(1222);
2026-07-20 16:05:17 +00:00
} else {
2026-08-08 06:10:11 +00:00
const privateChannel = channel_id(5129).selectPrivateChannel(tmp.id);
const obj2 = channel_id(5129);
2026-07-20 16:05:17 +00:00
}
return tmp2;
});
2026-07-23 10:11:24 +00:00
const nextPromise = server.storeWait(socket, () => outer1_5.getChannel(channel_id), num).catch(() => {
2026-08-08 06:10:11 +00:00
throw new channel_id(10736)({ 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-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
let tmp16 = channel_id(outer1_2[9]);
2026-07-20 16:05:17 +00:00
tmp16 = new tmp16(obj, "Invalid channel id: " + channel_id);
throw tmp16;
2026-07-23 10:11:24 +00:00
} else if (outer1_4(type.type)) {
2026-07-20 16:05:17 +00:00
const items = [Promise.resolve(type), ];
2026-07-23 10:11:24 +00:00
const obj2 = socket(outer1_2[10]);
items[1] = obj2.transformChannel(type, socket(outer1_2[10]).hasMessageReadPermission(type, socket.application.id, socket.authorization.scopes));
2026-07-20 16:05:17 +00:00
return Promise.all(items);
} else {
2026-07-29 08:29:29 +00:00
obj = { errorCode: null };
obj[0] = outer1_12.INVALID_CHANNEL;
const tmp7 = new channel_id(outer1_2[9])(obj, "Channel is not a text channel");
throw tmp7;
2026-07-20 16:05:17 +00:00
}
});
} else {
2026-07-29 08:29:29 +00:00
socket(1222).transitionTo(constants.ME);
2026-07-20 16:05:17 +00:00
nextPromise1 = null;
2026-07-29 08:29:29 +00:00
let obj = socket(1222);
2026-07-20 16:05:17 +00:00
}
return nextPromise1;
}
};
obj[RPCCommands.CREATE_CHANNEL_INVITE] = {
2026-07-23 10:11:24 +00:00
scope: require("set").OAuth2Scopes.RPC,
handler(args) {
args = args.args;
const channel_id = args.channel_id;
2026-07-29 08:29:29 +00:00
const merged = Object.assign(args, Object.create(null));
2026-08-08 06:10:11 +00:00
const invite = importDefault(7758).createInvite(channel_id, merged, "RPC");
2026-07-23 10:11:24 +00:00
return invite.catch(() => {
let tmp = outer1_1(outer1_2[9]);
tmp = new tmp({ errorCode: outer1_12.INVALID_PERMISSIONS }, "Unable to generate an invite for " + channel_id + ". Does this user have permissions?");
throw tmp;
});
}
};
const obj8 = {
scope: require("set").OAuth2Scopes.RPC,
2026-07-20 16:05:17 +00:00
handler(args) {
args = args.args;
const channel_id = args.channel_id;
2026-07-29 08:29:29 +00:00
const merged = Object.assign(args, Object.create(null));
2026-08-08 06:10:11 +00:00
const invite = importDefault(7758).createInvite(channel_id, merged, "RPC");
2026-07-20 16:05:17 +00:00
return invite.catch(() => {
2026-07-23 10:11:24 +00:00
let tmp = outer1_1(outer1_2[9]);
tmp = new tmp({ errorCode: outer1_12.INVALID_PERMISSIONS }, "Unable to generate an invite for " + channel_id + ". Does this user have permissions?");
2026-07-20 16:05:17 +00:00
throw tmp;
});
}
};
2026-07-29 08:29:29 +00:00
const result = require("createGuildRecordFromRust").fileFinishedImporting("modules/rpc/server/commands/channels.tsx");
2026-07-20 16:05:17 +00:00
export default obj;