Advertisement
Guest User

Untitled

a guest
Oct 27th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. //Megabot Setup
  2. const mineflayer = require('mineflayer');
  3. const Vec3 = require('vec3').Vec3;
  4. //Variables
  5. var version = ('a1.3');
  6. var admin = ('aptget_');
  7. var host = ('metoothanks.ca');
  8. var port = ('25565');
  9. var user = ('deez');
  10. var pass = ('nuts');
  11. var time = new Date();
  12. var month = time.getMonth()+1;
  13. var day = time.getDate();
  14. var year = time.getFullYear();
  15. var date = month+'/'+day+'/'+year;
  16. var prefix = ('?');
  17. var msg = ('/msg ');
  18. var permissionerror = ('Error: not enough permissions');
  19. var argserror = ('Error: no arguments');
  20. //bot creation
  21. console.log('Initializing MegaBOT '+version);
  22. console.log('Connecting to '+host+':'+port);
  23. console.log('Account '+user);
  24.  
  25. var bot = mineflayer.createBot({
  26. host: host,
  27. port: port,
  28. username: user,
  29. password: pass,
  30. verbose: true,
  31. });
  32.  
  33. bot.on('chat', (username, message) => {
  34.  
  35. if (username === bot.username) return;
  36. if (!message.startsWith(prefix)) return;
  37.  
  38. var index = message.indexOf(" ");
  39.  
  40. if (index < 0) {
  41.  
  42. var keyword = message.substring(prefix.length);
  43. var args = [];
  44.  
  45. } else {
  46.  
  47. var keyword = message.substring(prefix.length, index);
  48. var args = message.substring(index + 1).split(" | ");
  49. }
  50.  
  51. console.log("Command: " + keyword);
  52. console.log("Arguments: " + args);
  53.  
  54. if (keyword === "ignore") {
  55. ignore(username, args);
  56. } else if (keyword === "prefix") {
  57. prefix(username, args);
  58. } else if (keyword === "say") {
  59. say(username, args);
  60. }
  61. function ignore(username, args) {
  62. if (username === "aptget_") {
  63. bot.chat("i ran /ignore "+args);
  64. bot.chat("/ignore "+args);
  65. console.log("ran /ignore "+args);
  66. } else if (args === []) {
  67. bot.chat(msg+username+argserror);
  68. } else {
  69. bot.chat(msg+username+permissionerror);
  70. console.log(username+": "+permissionerror);
  71. }
  72. }
  73. })
  74. // bot.on('login', (username) => {
  75. // bot.chat('/ignore aptget_')
  76. // })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement