Advertisement
Guest User

Untitled

a guest
Apr 13th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. // -- Variables --
  2. const Discord = require('discord.js');
  3. const client = new Discord.Client();
  4. var logindata = require('./login.json')
  5. var config = require('./config.json')
  6. var mineflayer = require('mineflayer');
  7. var blacklist = ["test","nigger","nig","niglet","negro","blacky","darky","towelhead","dothead","nigga","niggy"]
  8. let bot;
  9. let i;
  10. let moveon;
  11. client.login(config.token);
  12. // -- End Variables --
  13.  
  14. // -- Functions --
  15. String.prototype.replaceAll = function(search, replacement) {
  16. let target = this;
  17. return target.replace(new RegExp(search, 'g'), replacement);
  18. z = true;
  19. };
  20.  
  21. function bindevents(bot){
  22. bot.on('error', function(err){
  23. console.log("bot ran into an error");
  24. console.log(err);
  25. })
  26. };
  27.  
  28. function relog(){
  29. bindevents(bot)
  30. bot()
  31. }
  32. // -- End Functions --
  33.  
  34. // -- Login --
  35. function loginbot(){
  36. bot = mineflayer.createBot({
  37. host: logindata.server,
  38. port: "25565",
  39. username: logindata.email,
  40. password: logindata.password,
  41. version: logindata.version
  42. })
  43. };
  44. // -- End Login --
  45.  
  46. loginbot();
  47.  
  48. bot.on('login',() => {
  49. console.log("Logged in!")
  50. });
  51.  
  52. bot.on('kicked', () => {
  53. bot.quit()
  54. setTimeout(relog, 10000)
  55. })
  56.  
  57. // -- Message --
  58. bot.on('message', (chatMessage) => {
  59. let filt;
  60. let rankFormat = chatMessage.extra[0].text.toString(); let rank = rankFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
  61. let nameFormat = chatMessage.extra[1].text.toString(); let name = nameFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
  62. let splitFormat = chatMessage.extra[2].text.toString(); let format = splitFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
  63. let msg = `${chatMessage}`.split(format).pop(); let y = msg.split(" ")
  64.  
  65. // -- Filtering --
  66. for(let i = 0; i < y.length; i++){
  67. console.log(i)
  68. if(y[i].includes("@")){
  69. y[i] = y[i].replace("@","at ")
  70. }
  71. if(y[i].includes("`")){
  72. console.log("test")
  73. }
  74. if(y[i].includes("_")){
  75. console.log("test")
  76. }
  77. if(y[i].includes("*")){
  78. console.log("test")
  79. }
  80. if(i = y.length){
  81. moveon = true;
  82. }
  83. }
  84. // -- End Filtering --
  85.  
  86. if(moveon == true){
  87.  
  88. // -- Word Blacklist --
  89. for(i in blacklist){
  90. msg = msg.replaceAll(blacklist[i], "**" + blacklist[i] + "**");
  91. if(msg.includes(blacklist[i])){
  92. filt = true;
  93. }
  94. }
  95. // -- End Blacklist --
  96. moveon == false;
  97.  
  98. if(filt == true){
  99. // client.channels.get(config.filter).send(rank + name + format + msg);
  100. console.log(y)
  101. console.log("true")
  102. } else {
  103. //client.channels.get(config.relay).send(rank + name + format + msg);
  104. console.log("false")
  105. }
  106. }
  107. }
  108. );
  109. // -- End Message --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement