Skip to main content

Bot

In this section of the documentation, I will show you methods which you can use to manage and create Bots.

Getting started with the BotManager

To get started with the BotManager, you need to get the BotManager class from the MooMoo API.

const BotManager = MooMoo.BotManager;

Creating a new Bot

To create a new Bot, you can use the BotManager.Bot class.

const Bot = new BotManager.Bot();

I have documented the process of creating a bot in an example already here

Once you have created a bot, you can use the BotManager.addBot method to add the bot to the BotManager.

const bot1 = BotManager.addBot(Bot)

This will return an ID, which you can use to access the bot later.

const thatonebot = BotManager.getBot(bot1);

Bot methods

ws

You can use the ws to directly use the bot's ws. The ws property is set when the connected event is emitted.

let botws = null;

Bot.addEventListener("connected", () => {
botws = Bot.ws;
})

sendPacket

You can use the sendPacket to directly send a packet to the server. its useful because the packet you will be sending is going to be automatically encoded, so you wont have to worry about that.

Bot.sendPacket("ch", "Hello World!")

packets

The event packets will submit a new packet event every time the bot has received a packet from the server. It is going to be automatically decoded, so you wont have to worry about that.

Bot.addEventListener("packet", (packetData) => {
let packet = packetData.packet;
let data = packetData.data;

// ...
})

spawn

You can use the spawn method to spawn the bot in the server. The name, skin and moofoll for the spawn event are the ones you have set in the constructor.

Bot.spawn();

That's it. You can now use the bot to do whatever you want.