New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mineflayer-cmd

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mineflayer-cmd

A simple command handler plugin for Mineflayer.

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
28
-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

mineflayer-cmd

A simple command manager and handler for Mineflayer plugins.

Getting Started

This plugin is built using Node and can be installed using:

npm install --save mineflayer-cmd

Simple Bot

Loading the plugin can be done the same as any other plugin. Commands can also be loaded at any time.

// Create your bot
const mineflayer = require("mineflayer");
const bot = mineflayer.createBot({ username: "Player" });

// Load the cmd plugin
const cmd = require('mineflayer-cmd').plugin

cmd.allowConsoleInput = true // Optional config argument
bot.loadPlugin(cmd)

// Register your custom command handlers, if desired (plugins can load them too)
function sayCommand(sender, flags, args, cb) {

  let message = ''

  if (flags.showsender) message += sender + ": "
  if (flags.color) message += '&' + flags.color[0]

  message += args.join(' ')
  bot.chat(message)

  cb()
}

bot.once('cmd_ready', () => {
  bot.cmd.registerCommand('say', sayCommand, // Create a new command called 'say' and set the executor function
            'make me say something', // help text
            'say <message>') // usage text

         // Add a flag called 'color' that expects 1 input
         .addFlag('color', 1, ['color code'], 'Changes the chat color')

         // Add a flag called 'showsender' that expects 0 inputs
         .addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
})

// And listen for command inputs from any source
// Let's listen for chat events that start with "!"
bot.on('chat', (username, message) => {
  if (message.startsWith('!')) {
    const command = message.substring(1)
    bot.cmd.run(username, command) // Run with the sender and the command itself
  }
})

Documentation

API

Examples

License

This project uses the MIT license.

Contributions

This project is accepting PRs and Issues. See something you think can be improved? Go for it! Any and all help is highly appreciated!

For larger changes, it is recommended to discuss these changes in the issues tab before writing any code. It's also preferred to make many smaller PRs than one large one, where applicable.

Keywords

mineflayer

FAQs

Package last updated on 11 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts