Files
BridgeSwarm/native-host/discord/registry.js
T
snxraven 693814f46b
CI / Build & Test (push) Failing after 52s
Add Discordjs
2026-09-04 22:10:35 -04:00

30 lines
768 B
JavaScript

/**
* Live binding filled by packed.js when that file is statically imported
* so bare-pack rewrites discord.js into the host bundle.
*/
const registry = { module: null };
function registerPackedDiscordJs(mod) {
const unwrapped = unwrapDiscordModule(mod);
registry.module = unwrapped || null;
return registry.module;
}
function takePackedDiscordJs() {
return registry.module;
}
function unwrapDiscordModule(mod) {
if (!mod || typeof mod !== 'object') return undefined;
if (typeof mod.Client === 'function') return mod;
const def = mod.default;
if (def && typeof def === 'object' && typeof def.Client === 'function') return def;
return undefined;
}
module.exports = {
registerPackedDiscordJs,
takePackedDiscordJs,
unwrapDiscordModule,
};