decord/alpha/source/modules/instant_invite/InviteCodeUtils.tsx

144 lines
4.8 KiB
TypeScript
Raw Permalink Normal View History

2026-10-10 08:08:14 +00:00
// Module ID: 5074
// Function ID: 5075
// Name: InviteCodeUtils
2026-10-10 08:08:14 +00:00
// Dependencies: [32, 11, 1491, 5075, 2]
2026-07-29 08:29:29 +00:00
// Exports: generateInviteKeyFromUrlParams, getInviteInstanceId, getInviteKeySearchSuffix, parseExtraDataFromInviteKey, parseInviteCodeFromInviteKey
2026-07-20 16:05:17 +00:00
2026-10-10 08:08:14 +00:00
// Module 5074 (InviteCodeUtils)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
2026-10-09 10:00:15 +00:00
import _modDef1491 from "module_1491" /* 1491 */;
2026-10-10 08:08:14 +00:00
import QueryStringUtils from "QueryStringUtils" /* 5075 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function readSnowflake(firstQueryStringValue) {
let tmp;
2026-08-04 21:03:28 +00:00
if (typeof firstQueryStringValue === "string") {
2026-10-03 08:58:59 +00:00
const obj = SnowflakeUtilsDefault;
2026-07-20 16:05:17 +00:00
if (obj.isProbablyAValidSnowflake(firstQueryStringValue)) {
tmp = firstQueryStringValue;
}
}
return tmp;
}
function generateInviteKeyFromExtraData(arg0) {
2026-10-03 08:58:59 +00:00
let baseCode;
let guildScheduledEventId;
let targetChannelId;
let targetMessageId;
({ baseCode, guildScheduledEventId, targetChannelId, targetMessageId } = arg0);
2026-07-20 16:05:17 +00:00
const obj = {};
if (null != guildScheduledEventId) {
2026-07-23 10:11:24 +00:00
obj[event] = guildScheduledEventId;
2026-07-20 16:05:17 +00:00
}
if (null != targetChannelId) {
2026-07-23 10:11:24 +00:00
obj[channel] = targetChannelId;
2026-07-20 16:05:17 +00:00
if (null != targetMessageId) {
2026-07-23 10:11:24 +00:00
obj[message] = targetMessageId;
2026-07-20 16:05:17 +00:00
}
}
2026-10-09 10:00:15 +00:00
const obj2 = _modDef1491;
2026-10-03 08:58:59 +00:00
const json = obj2.stringify(obj);
2026-07-20 16:05:17 +00:00
let combined = baseCode;
if ("" !== json) {
const _HermesInternal = HermesInternal;
combined = "" + baseCode + "?" + json;
}
return combined;
}
2026-07-23 10:11:24 +00:00
const event = "event";
const channel = "channel";
const message = "message";
const result = size.fileFinishedImporting("modules/instant_invite/InviteCodeUtils.tsx");
2026-07-20 16:05:17 +00:00
export { readSnowflake };
export const generateInviteKeyFromUrlParams = function generateInviteKeyFromUrlParams(match2, search) {
2026-10-03 08:58:59 +00:00
let tmp9Result;
2026-07-20 16:05:17 +00:00
if (null == search) {
return match2;
2026-07-20 16:05:17 +00:00
} else {
let substr = search;
if ("?" === search.charAt(0)) {
substr = search.substring(1);
}
2026-07-29 08:29:29 +00:00
try {
2026-10-09 10:00:15 +00:00
const obj = _modDef1491;
2026-10-03 08:58:59 +00:00
const parsed = obj.parse(substr);
const obj2 = QueryStringUtils;
const firstQueryStringValue = obj2.getFirstQueryStringValue(parsed[event]);
const obj3 = QueryStringUtils;
const tmp11 = readSnowflake(obj3.getFirstQueryStringValue(parsed[channel]));
const obj4 = { baseCode: match2, guildScheduledEventId: firstQueryStringValue, targetChannelId: tmp11, targetMessageId: tmp9Result };
tmp9Result = undefined;
const tmp12 = generateInviteKeyFromExtraData;
const tmp5 = require;
const tmp9 = readSnowflake;
if (null != tmp11) {
2026-10-10 08:08:14 +00:00
const tmp5Result = tmp5(5075);
2026-10-03 08:58:59 +00:00
tmp9Result = tmp9(tmp5Result.getFirstQueryStringValue(parsed[message]));
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
return tmp12(obj4);
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-10-03 08:58:59 +00:00
return match2;
2026-07-20 16:05:17 +00:00
}
}
};
export { generateInviteKeyFromExtraData };
export const parseExtraDataFromInviteKey = function parseExtraDataFromInviteKey(inviteKey) {
2026-10-03 08:58:59 +00:00
let tmp2;
let tmp3;
let tmp5;
[tmp2, tmp3] = inviteKey.split("?");
2026-10-03 08:58:59 +00:00
_slicedToArray(inviteKey.split("?"), 2);
2026-07-29 08:29:29 +00:00
if (null == tmp3) {
2026-10-03 08:58:59 +00:00
return { baseCode: tmp2 };
2026-07-20 16:05:17 +00:00
} else {
2026-10-09 10:00:15 +00:00
const obj4 = _modDef1491;
2026-10-03 08:58:59 +00:00
const parsed = obj4.parse(tmp3);
const obj5 = QueryStringUtils;
const firstQueryStringValue = obj5.getFirstQueryStringValue(parsed[event]);
const obj6 = QueryStringUtils;
const firstQueryStringValue1 = obj6.getFirstQueryStringValue(parsed[channel]);
2026-07-29 08:29:29 +00:00
let tmp4;
2026-10-03 08:58:59 +00:00
const tmp12 = require;
2026-08-04 21:03:28 +00:00
if (typeof firstQueryStringValue1 === "string") {
2026-10-03 08:58:59 +00:00
const tmp9Result = SnowflakeUtilsDefault;
2026-07-29 08:29:29 +00:00
if (tmp9Result.isProbablyAValidSnowflake(firstQueryStringValue1)) {
tmp4 = firstQueryStringValue1;
}
}
2026-10-03 08:58:59 +00:00
const obj = { baseCode: tmp2, guildScheduledEventId: firstQueryStringValue, targetChannelId: tmp4, targetMessageId: tmp5 };
tmp5 = undefined;
2026-07-29 08:29:29 +00:00
if (null != tmp4) {
2026-10-10 08:08:14 +00:00
const tmp12Result = tmp12(5075);
2026-10-03 08:58:59 +00:00
const firstQueryStringValue2 = tmp12Result.getFirstQueryStringValue(parsed[message]);
2026-07-29 08:29:29 +00:00
let tmp8;
2026-08-04 21:03:28 +00:00
if (typeof firstQueryStringValue2 === "string") {
2026-10-03 08:58:59 +00:00
const tmp9Result2 = SnowflakeUtilsDefault;
if (tmp9Result2.isProbablyAValidSnowflake(firstQueryStringValue2)) {
2026-07-29 08:29:29 +00:00
tmp8 = firstQueryStringValue2;
}
}
tmp5 = tmp8;
2026-07-20 16:05:17 +00:00
}
return obj;
}
2026-07-29 08:29:29 +00:00
};
export const parseInviteCodeFromInviteKey = function parseInviteCodeFromInviteKey(code) {
return _slicedToArray(code.split("?"), 1)[0];
2026-07-20 16:05:17 +00:00
};
export const getInviteKeySearchSuffix = function getInviteKeySearchSuffix(inviteKeyFromExtraData) {
const index = inviteKeyFromExtraData.indexOf("?");
let str = "";
if (index >= 0) {
str = inviteKeyFromExtraData.substring(index);
}
return str;
};
export const getInviteInstanceId = function getInviteInstanceId(code, id) {
if (null != id) {
const _HermesInternal = HermesInternal;
return "" + id + ":" + _slicedToArray(code.split("?"), 1)[0];
2026-07-20 16:05:17 +00:00
}
};