30 lines
768 B
JavaScript
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,
|
|
};
|