Closed ghost closed 3 years ago
Fill out the template, or paste the code please
So I am saving the bots in an array with bots.push(bot); and looping throught them with for(let b of bots) { b.chat("hi"); }
But it isn't working only with one bot
If I create a bot and chatting with him it don't do anything.
Could you send the code where you push bots to the array?
let botsArray = []; function initBot(options) { let bot = mineflayer.createBot(options); bot.on('chat', function (username, message) { console.log("[CHAT/" + bot._client.username + "] <" + username + "> " + message) })
bot.on('connect', function () {
console.info("[CONNECTION/" + bot._client.username + "] Connected!");
});
bot.on('kicked', async (reason, loggedIn) => {onKick(reason, loggedIn)})
bot.on('error', () => {setTimeout(() => {bot.connect(options)})})
function onKick(reason, loggedIn) {
console.log("[KICK/]", reason, "\nLoggedIn: ", loggedIn)
if (json.modules.reconnectOnKick.enabled)
bot.connect(options)
}
bots.push(bot);
return bot;
}
And how can I get the raw message of bot.on('chat')?
So do you know how to fix this?
Show your full code in a code block (```) but most likely you are using bot.chat before the "spawn" event
no I am not
I added a command for this
I can walk with them etc.
Now its working?!!!
Great, next time follow the template, it's very hard to help if you provide almost no information
I think npm install minecraft-protocl
fixes it
Hello! Can I help you?
const mineflayer = require('mineflayer');
const bot = mineflayer.createBot({ host: 'mc.masedworld.net', port: 25565, username: 'milfoochkaa', version: '1.16' });
bot.once('spawn', () => { bot.on('chat', (username, message) => { if (username === bot.username) return; // игнорируем свои сообщения if (message.startsWith('!invite')) { const playerName = message.split(' ')[1]; inviteToClan(playerName); } });
bot.navigate.on('pathPartFound', function (path) {
bot.chat(Going ${path.length} meters in the general direction for now.
);
});
bot.navigate.on('cannotFind', function (closestPath) {
bot.chat(Unable to find path. Getting as close as possible.
);
bot.navigate.walk(closestPath);
});
bot.navigate.on('arrived', function () { bot.chat('I have arrived'); });
bot.setControlState('forward', true);
setTimeout(() => { bot.setControlState('forward', false); bot.setControlState('right', true);
setTimeout(() => {
bot.setControlState('right', false);
bot.setControlState('forward', true);
setTimeout(() => {
bot.setControlState('forward', false);
setInterval(() => {
checkNearbyPlayers();
}, 10000);
}, 5000);
}, 800);
}, 2000); });
const inviteCooldown = 10 * 1000; let inviteCount = 0;
function inviteToClan(playerName) {
bot.chat(/c invite ${playerName}
);
inviteCount++;
setTimeout(() => {
inviteCount--;
}, inviteCooldown);
}
function checkNearbyPlayers() { const players = bot.players; for (const playerName in players) { const player = players[playerName].entity; if (player && bot.entity.position.distanceTo(player.position) <= 50 && inviteCount < 2) { inviteToClan(playerName); } } }
const adMessages = [ "!&8&l&oПрисоединяйся к клану &4&l&oEndlessSeas&8&l&o и получай невероятное удовольствие! &f&o&n/warp EndLessSe", "!&8&l&oПрисоединяйся к клану &4&l&oEndlessSeas&8&l&o и получай невероятное удовольствие! &f&o&n/warp EndLessSe", "!&8&l&oИщешь клан для игры? &4&l&oEndlessSeas&8&l&o ждет тебя! Присоединяйся и стань частью команды! &f&o&n/warp EndLessSe", "!&4&l&oEndlessSeas&8&l&o - это не просто клан, это сплоченная команда единомышленников! &f&o&n/warp EndLessSe", "!&8&l&oВступай в кланс и получай поддержку и помощь в игре! &f&o&n/warp EndLessSe", "!&8&l&oХочешь играть в команде профессионалов? Тогда присоединяйся к &4&l&oEndlessSeas&8&l&o! &f&o&n/warp EndLessSe", "!&8&l&o&4&l&oEndlessSeas&8&l&o - это клан, который всегда поддержит своих участников! Присоединяйся! &f&o&n/warp EndLessSe", "!&8&l&oУстал играть один? В клане &4&l&oEndlessSeas&8&l&o ты найдешь новых друзей и единомышленников! &f&o&n/warp EndLessSe", "!&8&l&o&4&l&oEndlessSeas&8&l&o - это клан, где каждый может проявить свои навыки и достичь высот в игре! &f&o&n/warp EndLessSe", "!&8&l&oХочешь быть ебанутьм? Тогда не присоединяйся к &4&l&oEndlessSeas&8&l&o! &f&o&n/warp EndLessSe" ];
setInterval(() => { const message = adMessages[Math.floor(Math.random() * adMessages.length)]; bot.chat(message); }, 80000);
setInterval(() => { bot.chat('/warp qdwqvdusасiuvausi_zxов'); }, 5000);
Error
bot._client.chat(smallMsg) ^
TypeError: bot._client.chat is not a function
at c:\Users\Acer\Desktop\stock\node_modules\mineflayer\lib\plugins\chat.js:177:21
at Array.forEach (
Node.js v18.16.0
Hello, the function bot.chat(message) isn't working. Please help. Thank you.