Advertisement
namejeff

Untitled

Oct 28th, 2017
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. //Bot
  2. const mineflayer = require("mineflayer");
  3. const Vec3 = require("vec3").Vec3;
  4.  
  5. //Setup Variables
  6. var host = ("metoothanks.ca");
  7. var port = ("25565");
  8. var ip = (host+":"+port);
  9. var user = ("apt.79821@supermail.xyz");
  10. var pass = ("lejeff999");
  11. var space = (" ");
  12.  
  13. //Setup
  14. var bot = mineflayer.createBot({
  15. host: host,
  16. port: port,
  17. username: user,
  18. password: pass,
  19. verbose: true,
  20. });
  21.  
  22. //Bot Variables
  23. var prefix = ('?');
  24. var version = ('a0 Recoded');
  25. var admin = ('aptget_');
  26.  
  27. //Command Variables
  28. var msg = ('/tell ');
  29. var ignore = ('/ignore ');
  30.  
  31. //Errors
  32. var error = ('Error: ');
  33. var permissionerror = ('Not enough permissions');
  34. var commanderror = ('Unknown command');
  35. var genericerror = ('Generic error');
  36. var kicked = ('Kicked for');
  37. var argumenterror = ('Incorrect arguments');
  38. var cannotignore = ('Cannot ignore that player');
  39.  
  40. //Help Variables
  41. var helpList = [
  42. " ]---[MegaBOT Commands]---[",
  43. " ]---[Prefix: "+prefix+"]---[",
  44. " ]---[Version: "+version+"]---["
  45. ];
  46.  
  47. //Etc Variables
  48. var colon = (":");
  49. var motds = [
  50. "name jeff",
  51. "deez nuts",
  52. "i like big weener",
  53. "le me me"
  54. ]
  55. var blacklist = [
  56. "jeff"
  57. ]
  58.  
  59. function updateTime() {
  60. var date = new Date();
  61. var year = date.getFullYear();
  62. var month = date.getMonth() + 1;
  63. var day = date.getDate();
  64. var hours = date.getHours();
  65. var minutes = date.getMinutes();
  66. var seconds = date.getSeconds();
  67. time = ("["+day+colon+hours+colon+minutes+colon+seconds+"] ");
  68. }
  69. setInterval(updateTime, 1000)
  70. var motdNum = motds[Math.floor(Math.random() * motds.length)];
  71.  
  72. //Chat
  73. bot.on('chat', (username, message) => {
  74. var name = username.trim();
  75. if (!message.startsWith(prefix)) return;
  76. if (name === bot.username || blacklist.includes(name)) return;
  77.  
  78. var index = message.indexOf(" ");
  79.  
  80. if (index < 0) {
  81.  
  82. var keyword = message.substring(prefix.length);
  83. var args = [];
  84.  
  85. } else {
  86.  
  87. var keyword = message.substring(prefix.length, index);
  88. var args = message.substring(index + 1).split(" & ");
  89. }
  90.  
  91. console.log("Command: " + keyword);
  92. console.log("Arguments: " + args.join(", "));
  93. if (keyword === "quit") {
  94. doQuit(username, message);
  95. } else if (keyword === "motd") {
  96. bot.chat("MOTD: "+motdNum)
  97. } else if (keyword === "time") {
  98. doTime(username, message, args);
  99. } else if (bot.health === 10) {
  100. bot.chat("!!! Help, my health is below half! !!!")
  101. } else if (keyword === "ignore") {
  102. doIgnore(username, message, args)
  103. }
  104. function doTime(username, message, args) {
  105. if (args[0] === "irl") {
  106. bot.chat(time);
  107. } else if (args[0] === "minecraft") {
  108. bot.chat("["+bot.time.day % 24000 +"]");
  109. } else {
  110. bot.chat(msg+username+error+argumenterror)
  111. }
  112. }
  113. function doQuit(username, message) {
  114. if (name === admin) {
  115. bot.chat(msg+username+space+shutdown+time)
  116. console.log(time+shutdown);
  117. function runQuit() {
  118. bot.quit();
  119. }
  120. runQuit();
  121. } else {
  122. bot.chat(msg+username+space+error+permissionerror);
  123. }
  124. }
  125. function doIgnore(username, message, args) {
  126. if (name === admin) {
  127. if (args[0] === " " || args[0] === "" || args[0] === null || args[0] === undefined) {
  128. bot.chat(msg+username+error+argumenterror);
  129. console.log(time+username+"| Argument error");
  130. } else if (args[0] === admin) {
  131. bot.chat(msg+username+error+cannotignore);
  132. console.log(time+username+"| Cannot ignore "+args[0]);
  133. } else {
  134. bot.chat(ignore+args[0])
  135. bot.chat(msg+username+"I ignored "+args[0]);
  136. console.log(time+username+"| Ignored "+args[0]);
  137. }
  138. } else {
  139. bot.chat(msg+username+error+permissionerror);
  140. console.log(time+username+"| Does not have permissions for "+ignore);
  141. }
  142. }
  143. })
  144.  
  145. //Bot Events
  146. bot.on('kicked', (reason) => {
  147. console.log(time+error+kicked+` ${reason}`)
  148. })
  149.  
  150. bot.on('login', (username, message) => {
  151. doLoginFunc();
  152. function doLoginFunc() {
  153. bot.chat(time+"MOTD: "+motdNum)
  154. }
  155. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement