Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //isaacOS
- function sendChat(Text) { //Shorter version of MPP.chat.send
- MPP.chat.send(Text)
- }
- IOS = MPP;
- //IOS stands for IsaacOS. You can change IOS to anything, but note you have to change all the remaining IOS to what ever you put, so be mindful.
- IOS.client.on('a', function(msg) {
- var cmd = msg.a.split(' ')[0].toLowerCase(); //All commands must be in lowercase. prefix + "Kill" -> prefix + "kill"
- var input = msg.a.substring(cmd.length).trim(); //This is your substring, aka the input that is after the command. (cmd.length) makes the substring as long as the input, so you wont have to fiddle with numbers.
- var name = msg.p.name //The name variable says the name of the person who says the command.
- var prefix = '/' //This can be changed to anything, as long as it is one character. This is what comes before your command. /help can become ^help or ?help
- //The reason we use == is because it compares cmd to a term in chat.
- //Your bot scans all things sent in chat and compares to cmd.
- //If the message does not match cmd, it does nothing.
- //If you use one =, it will permanently set cmd to what you put.
- if (cmd == prefix + 'help') { //We put prefix in the list of commands so we dont need to automatically regenerate and spam the console.
- sendChat('Available commands: ' + prefix + 'help, ' + prefix + 'test, ' + prefix + 'say, ' + prefix + 'slap.');
- }
- if (cmd == prefix + 'about) {
- sendChat('IsaacOS is a bot written by Isaac using code from CitronSustain.');
- }
- if (cmd == prefix + 'test') {
- sendChat('If you see this, the bot works!');
- }
- if (cmd == prefix + 'say') { //This command says the input.
- sendChat(input) //also msg.a.substring(cmd.length).trim()
- }
- //Use back ticks (`) for strings because its easier to use ' and +.
- //Example:(name + 'hugs ' + input) becomes (`${name} hugs ${input}.`)
- //This is called String Interpolation. It is your friend.
- if (cmd == prefix + 'slap') { //This is String Interpolation.
- sendChat(`${name} slaps ${info(input).name}.`);
- }
- //If you want your command to have the a name and not just anything, use this function
- function info(name) {
- var array = [];
- for (var pl in IOS.client.ppl) {
- if (IOS.client.ppl[pl].name.toLowerCase().includes(name.toLowerCase())) {
- array.push(IOS.client.ppl[pl]);
- }
- }
- return array[Math.floor(Math.random() * array.length)];
- }
- //To use it, put info(input).name rather than just input.
- //Then, if you did /kill JP
- //This: person kills JP
- //Goes to this: person kills JPDLD.
- if (cmd == prefix + 'kill') {
- sendChat(`${name} kills ${info(input).name}.`)
- }
- });
- //If you put any commands under this point, they will not work!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement