Skip to content

Instantly share code, notes, and snippets.

@roxwize
Last active October 6, 2022 10:58
Show Gist options
  • Select an option

  • Save roxwize/97145a9a2a2625b0c3ba575c44bfa74c to your computer and use it in GitHub Desktop.

Select an option

Save roxwize/97145a9a2a2625b0c3ba575c44bfa74c to your computer and use it in GitHub Desktop.
MPP API documentation

Multiplayer Piano (Unofficial) Bot Documentation

While it is never explicitly stated within the website, Multiplayer Piano has bot support and its own API. Accessing it is simple. Everything is contained within the MPP object and it contains everything you need to get started.

Object functions and classes

chat

The chat object. Controls the sending and receiving of messages.

Functions

blur()

De-focuses the chat and places it in the background.

clear()

Removes every message in chat.

hide()

Removes chatlog from view.

receive(msg)

Sends a custom message to the client only. Used for the mentioning feature. msg is an object, with its values explained below.

  • a : Message
  • p : Optional parameters
    • name : Name of the fake user
    • color : Hex value of the text color
  • m : Message type. If "dm", the message acts as a direct message and makes use of msg.sender and msg.recipient.

Example

MPP.chat.receive({
	a: 'Hello, world!',
	p: {
		name: 'User',
		id: 'a4d979b59687e390796eb0ce',
		_id: 'a4d979b59687e390796eb0ce',
		color: '#0D1117'
	}
})

scrollToBottom()

Scrolls the chatlog to the most recent messages, if user has scrolled up.

send(message)

Sends a message.

show()

Makes chatlog visible again, if not already.

client

Contains everything pertaining to the current user and the room they are in.

Events

These, among every other event, can be used in tandem with addEventListener (or, preferably, MPP.client.on(event, function)) .

a

Fires when a user sends a message. msg can be passed in the callback function to receive information on the ID of the sender and the contents of the message, among others. Can be used to receive commands.

msg values
  • a : The contents of the message in plain text.
  • p : The object representing the player. (See Player for details)
Examples

Simple ping command

A simple script that utilizes a single variable and listener

// Prefix for the bot so they don't spam the chat
const PREFIX = "!";

// Listen for messages
MPP.client.on("a", (msg) => {
  if (msg.a === PREFIX + "ping") {
    // Check to see if the message is "!ping." Using the PREFIX variable allows you to change it without any tedium!
    MPP.chat.send("Pong!");
  }
});

Variables

channel

Contains information about the current room.

crown

Contains information about where the crown is, who it belongs to, and its duration.

settings

Contains information about the room's visibility

Notification

Basic notification class. When created, will display a notification atop the piano with an X on the top right to close.

How to create:

const notif = new MPP.Notification({ args })

Example:

Creates a notification that displays the text "This is a notification" with the title "Notification" const notif = new MPP.Notification({ title: 'Notification', text: 'This is a notification' })

Variables

id

The unique ID of the notification.

title

The title of the notification. Displays in bold.

text

The contents of the notification.

duration

How long the notification will stay on screen, in milliseconds, before disappearing. Defaults to 30000 (30 seconds).

Functions

close()

Closes the notification.

Player

The player object is not a predefined class or object. Each occurrence, however, typically shares the same traits. Note that some variables are specific to certain parents.

id or _id

The player's ID, used to identify them.

color

The color of the player's name and block.

name

The display name of the player.

x

The x position of the player's cursor.

y

The y position of the player's cursor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment