Advertisement
namejeff

Untitled

Oct 28th, 2017
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 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 = ("ilikemen@quickmail.org");
  10. var pass = ("minecraftpassword42");
  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. //Help Variables
  39. var helpList = [
  40. " ]---[MegaBOT Commands]---[",
  41. " ]---[Prefix: "+prefix+"]---[",
  42. " ]---[Version: "+version+"]---["
  43. ];
  44.  
  45. //Etc Variables
  46. var colon = (":");
  47. var motds = [
  48. "name jeff",
  49. "deez nuts",
  50. "i like big weener",
  51. "le me me"
  52. ]
  53. var blacklist = [
  54. "jeff"
  55. ]
  56.  
  57. function updateTime() {
  58. var date = new Date();
  59. var year = date.getFullYear();
  60. var month = date.getMonth() + 1;
  61. var day = date.getDate();
  62. var hours = date.getHours();
  63. var minutes = date.getMinutes();
  64. var seconds = date.getSeconds();
  65. time = ("["+day+colon+hours+colon+minutes+colon+seconds+"] ");
  66. }
  67. setInterval(updateTime, 1000)
  68. var motdNum = motds[Math.floor(Math.random() * motds.length)];
  69.  
  70. //Chat
  71. bot.on('chat', (username, message) => {
  72. var name = username.trim();
  73.  
  74. if (!message.startsWith(prefix)) return;
  75. if (name === bot.username || blacklist.includes(name)) return;
  76.  
  77. var index = message.indexOf(" ");
  78.  
  79. if (index < 0) {
  80.  
  81. var keyword = message.substring(prefix.length);
  82. var args = [];
  83.  
  84. } else {
  85.  
  86. var keyword = message.substring(prefix.length, index);
  87. var args = message.substring(index + 1).split(" & ");
  88. }
  89.  
  90. console.log("Command: " + keyword);
  91. console.log("Arguments: " + args.join(", "));
  92. if (keyword === "quit") {
  93. doQuit(username, message);
  94. } else if (keyword === "motd") {
  95. bot.chat("MOTD: "+motdNum)
  96. } else if (keyword === "time") {
  97. doTime(username, message, args);
  98. }
  99. function doTime(username, message, args) {
  100. if (args === "irl") {
  101. bot.chat(time);
  102. } else if (args === "minecraft") {
  103. bot.chat("["+bot.time.day % 24000 +"]");
  104. } else {
  105. bot.chat(msg+error+argumenterror)
  106. }
  107. }
  108. function doQuit(username, message) {
  109. if (username === "aptget_") {
  110. bot.chat(msg+username+space+shutdown+time)
  111. console.log(time+shutdown);
  112. function runQuit() {
  113. bot.quit();
  114. }
  115. runQuit();
  116. } else {
  117. bot.chat(msg+username+space+error+permissionerror);
  118. }
  119. }
  120. })
  121.  
  122. //Bot Events
  123. bot.on('kicked', (reason) => {
  124. console.log(time+error+kicked+` ${reason}`)
  125. })
  126.  
  127. bot.on('login', (username, message) => {
  128. doLoginFunc();
  129. function doLoginFunc() {
  130. bot.chat(time+"MOTD: "+motdNum)
  131. }
  132. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement