nxg-org / mineflayer-custom-pvp

Intermediate functionality for bow and sword pvp.
7 stars 1 forks source link

Error: plugin needs to be a function #41

Closed Asguho closed 6 days ago

Asguho commented 2 years ago
const mineflayer = require("mineflayer");
const customPVP = require("@nxg-org/mineflayer-custom-pvp/lib/index.js");
const login = require("../login.json");

const bot = mineflayer.createBot({
    host: "SERVERIP",   
    port: PORT,
    username: login.email,
    password: login.password,
    auth: 'microsoft'
})

bot.loadPlugin(customPVP)

bot.on("spawn", ()=>{
    bot.swordpvp.attack(bot.nearestEntity((e) => e.type === "player"));
})

when i run the code above, it gets an error when running "bot.loadPlugin(customPVP)". The error message:

Debugger attached. Waiting for the debugger to disconnect... node:assert:399 throw err; ^

AssertionError [ERR_ASSERTION]: plugin needs to be a function at EventEmitter.loadPlugin ([c:\PATHTOFOLDER\custom-pvp\node_modules\mineflayer\lib\plugin_loader.js:16:12]()) at Object. ([c:\PATHTOFOLDER\custom-pvp\index.js:13:5]()) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47 { generatedMessage: false, code: 'ERR_ASSERTION', actual: false, expected: true, operator: '=='

Ziro-Zan commented 4 months ago

I'm late, but if someone like me searches for a fix, here it is: go to node_modules\@nxg-org\mineflayer-custom-pvp\lib open index.js and change the last line: exports.default = plugin;

to: exports.plugin = plugin;

Ziro-Zan commented 4 months ago

I'm late, but if someone like me searches for a fix, here it is: go to node_modules@nxg-org\mineflayer-custom-pvp\lib open index.js and change the last line: exports.default = plugin;

to: exports.plugin = plugin;

Also, instead of using const customPVP = require("@nxg-org/mineflayer-custom-pvp/lib/index.js"); use const customPVP = require("@nxg-org/mineflayer-custom-pvp/lib/index.js").plugin

AjayAntoIsDev commented 1 month ago

@Ziro-Zan tysm