Skip to content

Instantly share code, notes, and snippets.

@Hri7566
Created November 10, 2023 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hri7566/6bd4a40cb9a6c98840946d8e39b17a26 to your computer and use it in GitHub Desktop.
Save Hri7566/6bd4a40cb9a6c98840946d8e39b17a26 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Gigachad Template
// @namespace Violentmonkey Scripts
// @match https://multiplayerpiano.net/*
// @grant none
// @version 1.0
// @author Hri7566
// @description 11/9/2023, 10:33:05 PM
// ==/UserScript==
// Command class
class Command {
static commands = [];
constructor(aliases, callback) {
this.aliases = aliases;
this.callback = callback;
Command.commands.push(this);
}
}
// Chat listener
let prefix = "!";
MPP.client.on("a", msg => {
if (!msg.a.startsWith(prefix)) return;
msg.args = msg.a.split(" ");
msg.usedCommand = msg.args[0].substring(prefix.length).trim();
for (const cmd of Command.commands) {
if (!cmd.aliases.includes(msg.usedCommand)) continue;
let out = cmd.callback(msg);
if (out) MPP.client.sendArray([{m: "a", message: out}]);
return;
}
});
// Commands
new Command(["help", "h", "cmds"], msg => {
return "Commands: " + Command.commands.map(cmd => prefix + cmd.aliases[0]).join(" | ");
});
new Command(["id"], msg => {
return "ID: `" + msg.p._id + "`";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment