MCBotJS is a one of a kind chat bot creator. Utilize your JavaScript skills to quickly deploy custom bots with loads of features using the
MCBotJS API.
The plugin is and will continue to be in active development, so there may lack some features you'd like to see. If you want to recommend a feature for the API, please mention this in the discussion tab.
Commands /mcbot reload- Reloads all configs and scripts
Configuration Configure your bots in the configuration like so. The script section is a reference to a js file in the
scripts/ directory within the
MCBot/plugin directory.
This is just an example, further configs can be found in the documentation by following the guides.
With the example config, place the example code into a
MCBot/scripts/example.jsfile
Code (Java):
// Event which handles incoming chat messages function onMessageSend
(bot, message
){ // Retrieve the content of the message and the player who sent it var content
= message.
getContent(); var player
= message.
getPlayer();
// Perform different actions based on the content of the message switch(content
){ case"!hello": // Send a greeting message to the player who sent the command bot.
sendMessage("Hello "+ player.
getName()); break; case"!getRandomWord": // Make an HTTP GET request to fetch a random word from an API var response
= bot.
get("https://random-word-api.herokuapp.com/word"); // Parse the JSON response var responseJSON
= JSON.
parse(response
); // Send the random word to the server chat bot.
sendMessage(responseJSON
); break; } }
// Event which handles player join events function onPlayerJoin
(bot, player
){ // Construct a welcome message for the server var message
=""; if(player.
hasPlayedBefore()){ message
="Welcome back "+ player.
getName(); }else{ message
="Welcome "+ player.
getName(); } // Send the welcome message to the server bot.
sendMessage(message
); }