Created
November 10, 2023 04:26
-
-
Save Hri7566/6bd4a40cb9a6c98840946d8e39b17a26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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