I'm trying to load a library in preload.js
const { contextBridge } = require("electron");
const mineflayer = require("mineflayer");
contextBridge.exposeInMainWorld('libs', {
mine: mineflayer
});
In main.js I connect preload in this way
win = new BrowserWindow({
resizable: false,
width: 900,
height: 700,
autoHideMenuBar: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
sandbox: false
}
});
I want to use this library in index.js (js script of the index.html file)
The first method works but the next one does not work
lib.method() - works
lib.method(options).method() is not a function
const bot = libs.mine.createBot({option});
bot.on("message", msg => {console.log(msg)}); // bot.on it is not a function
I can’t solve this problem for 2 days, what’s the problem?