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.
The chat object. Controls the sending and receiving of messages.
De-focuses the chat and places it in the background.
Removes every message in chat.
Removes chatlog from view.
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 ofmsg.senderandmsg.recipient.
Example
MPP.chat.receive({
a: 'Hello, world!',
p: {
name: 'User',
id: 'a4d979b59687e390796eb0ce',
_id: 'a4d979b59687e390796eb0ce',
color: '#0D1117'
}
})Scrolls the chatlog to the most recent messages, if user has scrolled up.
Sends a message.
Makes chatlog visible again, if not already.
Contains everything pertaining to the current user and the room they are in.
These, among every other event, can be used in tandem with addEventListener (or, preferably, MPP.client.on(event, function)) .
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.
- a : The contents of the message in plain text.
- p : The object representing the player. (See Player for details)
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!");
}
});Contains information about the current room.
Contains information about where the crown is, who it belongs to, and its duration.
Contains information about the room's visibility
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' })
The unique ID of the notification.
The title of the notification. Displays in bold.
The contents of the notification.
How long the notification will stay on screen, in milliseconds, before disappearing. Defaults to 30000 (30 seconds).
Closes the notification.
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.
The player's ID, used to identify them.
The color of the player's name and block.
The display name of the player.
The x position of the player's cursor.
The y position of the player's cursor.