Advertisement
Guest User

isaacos bot starter

a guest
Nov 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. //isaacOS
  2. function sendChat(Text) { //Shorter version of MPP.chat.send
  3. MPP.chat.send(Text)
  4. }
  5.  
  6. IOS = MPP;
  7.  
  8. //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.
  9.  
  10. IOS.client.on('a', function(msg) {
  11. var cmd = msg.a.split(' ')[0].toLowerCase(); //All commands must be in lowercase. prefix + "Kill" -> prefix + "kill"
  12. 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.
  13. var name = msg.p.name //The name variable says the name of the person who says the command.
  14. 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
  15.  
  16. //The reason we use == is because it compares cmd to a term in chat.
  17. //Your bot scans all things sent in chat and compares to cmd.
  18. //If the message does not match cmd, it does nothing.
  19. //If you use one =, it will permanently set cmd to what you put.
  20.  
  21. if (cmd == prefix + 'help') { //We put prefix in the list of commands so we dont need to automatically regenerate and spam the console.
  22. sendChat('Available commands: ' + prefix + 'help, ' + prefix + 'test, ' + prefix + 'say, ' + prefix + 'slap.');
  23. }
  24.  
  25. if (cmd == prefix + 'about) {
  26. sendChat('IsaacOS is a bot written by Isaac using code from CitronSustain.');
  27. }
  28.  
  29. if (cmd == prefix + 'test') {
  30. sendChat('If you see this, the bot works!');
  31. }
  32.  
  33. if (cmd == prefix + 'say') { //This command says the input.
  34. sendChat(input) //also msg.a.substring(cmd.length).trim()
  35. }
  36.  
  37. //Use back ticks (`) for strings because its easier to use ' and +.
  38. //Example:(name + 'hugs ' + input) becomes (`${name} hugs ${input}.`)
  39. //This is called String Interpolation. It is your friend.
  40.  
  41. if (cmd == prefix + 'slap') { //This is String Interpolation.
  42. sendChat(`${name} slaps ${info(input).name}.`);
  43. }
  44.  
  45. //If you want your command to have the a name and not just anything, use this function
  46. function info(name) {
  47. var array = [];
  48. for (var pl in IOS.client.ppl) {
  49. if (IOS.client.ppl[pl].name.toLowerCase().includes(name.toLowerCase())) {
  50. array.push(IOS.client.ppl[pl]);
  51. }
  52. }
  53. return array[Math.floor(Math.random() * array.length)];
  54. }
  55. //To use it, put info(input).name rather than just input.
  56.  
  57. //Then, if you did /kill JP
  58. //This: person kills JP
  59. //Goes to this: person kills JPDLD.
  60.  
  61. if (cmd == prefix + 'kill') {
  62. sendChat(`${name} kills ${info(input).name}.`)
  63. }
  64. });
  65.  
  66.  
  67. //If you put any commands under this point, they will not work!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement