decord/source/modules/instant_invite/InviteCodeUtils.tsx

142 lines
4.9 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 4365
// Function ID: 4366
2026-07-20 16:05:17 +00:00
// Name: readSnowflake
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 11, 1484, 4366, 2]
2026-07-29 08:29:29 +00:00
// Exports: generateInviteKeyFromUrlParams, getInviteInstanceId, getInviteKeySearchSuffix, parseExtraDataFromInviteKey, parseInviteCodeFromInviteKey
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 4365 (readSnowflake)
2026-08-24 06:08:38 +00:00
import DISCORD_EPOCHDefault from "DISCORD_EPOCH" /* 11 */;
import parseDefault from "parse" /* 1484 */;
2026-08-25 06:04:03 +00:00
import getFirstQueryStringValue from "getFirstQueryStringValue" /* 4366 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "_slicedToArray" /* 32 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
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-07-20 16:05:17 +00:00
if (obj.isProbablyAValidSnowflake(firstQueryStringValue)) {
tmp = firstQueryStringValue;
}
2026-08-24 06:08:38 +00:00
obj = DISCORD_EPOCHDefault;
2026-07-20 16:05:17 +00:00
}
return tmp;
}
2026-07-29 08:29:29 +00:00
function generateInviteKeyFromExtraData(closure_1) {
({ baseCode, guildScheduledEventId, targetChannelId, targetMessageId } = closure_1);
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-08-24 06:08:38 +00:00
const json = parseDefault.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";
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/instant_invite/InviteCodeUtils.tsx");
2026-07-20 16:05:17 +00:00
export { readSnowflake };
export const generateInviteKeyFromUrlParams = function generateInviteKeyFromUrlParams(inviteHostRemainingPath, search) {
if (null == search) {
return inviteHostRemainingPath;
} else {
let substr = search;
if ("?" === search.charAt(0)) {
substr = search.substring(1);
}
2026-07-29 08:29:29 +00:00
try {
2026-08-24 06:08:38 +00:00
let obj = parseDefault;
2026-07-29 08:29:29 +00:00
const parsed = obj.parse(substr);
2026-08-24 06:08:38 +00:00
const firstQueryStringValue = getFirstQueryStringValue.getFirstQueryStringValue(parsed[event]);
const obj2 = getFirstQueryStringValue;
2026-07-29 08:29:29 +00:00
const tmp10 = readSnowflake;
const tmp6 = require;
2026-08-24 06:08:38 +00:00
const tmp12 = readSnowflake(getFirstQueryStringValue.getFirstQueryStringValue(parsed[channel]));
2026-07-29 08:29:29 +00:00
obj = { baseCode: null, guildScheduledEventId: null, targetChannelId: null, targetMessageId: null };
obj[0] = inviteHostRemainingPath;
obj[1] = firstQueryStringValue;
obj[2] = tmp12;
let tmp10Result;
if (null != tmp12) {
2026-08-25 06:04:03 +00:00
tmp10Result = tmp10(tmp6(4366).getFirstQueryStringValue(parsed[message]));
const tmp6Result = tmp6(4366);
2026-07-29 08:29:29 +00:00
}
obj[3] = tmp10Result;
return generateInviteKeyFromExtraData(obj);
} catch (err) {
return tmp;
2026-07-20 16:05:17 +00:00
}
}
};
export { generateInviteKeyFromExtraData };
export const parseExtraDataFromInviteKey = function parseExtraDataFromInviteKey(inviteKey) {
2026-07-29 08:29:29 +00:00
[tmp2, tmp3] = callback(inviteKey.split("?"), 2);
if (null == tmp3) {
let obj = { baseCode: null };
obj[0] = tmp2;
2026-07-20 16:05:17 +00:00
return obj;
} else {
2026-08-24 06:08:38 +00:00
const parsed = parseDefault.parse(tmp3);
const obj4 = parseDefault;
2026-07-29 08:29:29 +00:00
const tmp12 = require;
2026-08-24 06:08:38 +00:00
const firstQueryStringValue = getFirstQueryStringValue.getFirstQueryStringValue(parsed[event]);
const obj5 = getFirstQueryStringValue;
const firstQueryStringValue1 = getFirstQueryStringValue.getFirstQueryStringValue(parsed[channel]);
2026-07-29 08:29:29 +00:00
let tmp4;
2026-08-04 21:03:28 +00:00
if (typeof firstQueryStringValue1 === "string") {
2026-07-29 08:29:29 +00:00
let tmp9Result = tmp9(11);
if (tmp9Result.isProbablyAValidSnowflake(firstQueryStringValue1)) {
tmp4 = firstQueryStringValue1;
}
}
obj = { baseCode: null, guildScheduledEventId: null, targetChannelId: null, targetMessageId: null };
obj[0] = tmp2;
obj[1] = firstQueryStringValue;
obj[2] = tmp4;
let tmp5;
if (null != tmp4) {
2026-08-25 06:04:03 +00:00
const firstQueryStringValue2 = tmp12(4366).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-07-29 08:29:29 +00:00
tmp9Result = tmp9(11);
if (tmp9Result.isProbablyAValidSnowflake(firstQueryStringValue2)) {
tmp8 = firstQueryStringValue2;
}
}
tmp5 = tmp8;
2026-08-25 06:04:03 +00:00
const tmp12Result = tmp12(4366);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[3] = tmp5;
2026-07-20 16:05:17 +00:00
return obj;
}
2026-07-29 08:29:29 +00:00
const tmp = callback(inviteKey.split("?"), 2);
};
export const parseInviteCodeFromInviteKey = function parseInviteCodeFromInviteKey(code) {
return callback(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;
2026-07-29 08:29:29 +00:00
return "" + id + ":" + callback(code.split("?"), 1)[0];
2026-07-20 16:05:17 +00:00
}
};