Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -- Variables --
- const Discord = require('discord.js');
- const client = new Discord.Client();
- var logindata = require('./login.json')
- var config = require('./config.json')
- var mineflayer = require('mineflayer');
- var blacklist = ["test","nigger","nig","niglet","negro","blacky","darky","towelhead","dothead","nigga","niggy"]
- let bot;
- let i;
- let moveon;
- client.login(config.token);
- // -- End Variables --
- // -- Functions --
- String.prototype.replaceAll = function(search, replacement) {
- let target = this;
- return target.replace(new RegExp(search, 'g'), replacement);
- z = true;
- };
- function bindevents(bot){
- bot.on('error', function(err){
- console.log("bot ran into an error");
- console.log(err);
- })
- };
- function relog(){
- bindevents(bot)
- bot()
- }
- // -- End Functions --
- // -- Login --
- function loginbot(){
- bot = mineflayer.createBot({
- host: logindata.server,
- port: "25565",
- username: logindata.email,
- password: logindata.password,
- version: logindata.version
- })
- };
- // -- End Login --
- loginbot();
- bot.on('login',() => {
- console.log("Logged in!")
- });
- bot.on('kicked', () => {
- bot.quit()
- setTimeout(relog, 10000)
- })
- // -- Message --
- bot.on('message', (chatMessage) => {
- let filt;
- let rankFormat = chatMessage.extra[0].text.toString(); let rank = rankFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
- let nameFormat = chatMessage.extra[1].text.toString(); let name = nameFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
- let splitFormat = chatMessage.extra[2].text.toString(); let format = splitFormat.replace(/§[a-zA-Z0-9_.-]/gm, '');
- let msg = `${chatMessage}`.split(format).pop(); let y = msg.split(" ")
- // -- Filtering --
- for(let i = 0; i < y.length; i++){
- console.log(i)
- if(y[i].includes("@")){
- y[i] = y[i].replace("@","at ")
- }
- if(y[i].includes("`")){
- console.log("test")
- }
- if(y[i].includes("_")){
- console.log("test")
- }
- if(y[i].includes("*")){
- console.log("test")
- }
- if(i = y.length){
- moveon = true;
- }
- }
- // -- End Filtering --
- if(moveon == true){
- // -- Word Blacklist --
- for(i in blacklist){
- msg = msg.replaceAll(blacklist[i], "**" + blacklist[i] + "**");
- if(msg.includes(blacklist[i])){
- filt = true;
- }
- }
- // -- End Blacklist --
- moveon == false;
- if(filt == true){
- // client.channels.get(config.filter).send(rank + name + format + msg);
- console.log(y)
- console.log("true")
- } else {
- //client.channels.get(config.relay).send(rank + name + format + msg);
- console.log("false")
- }
- }
- }
- );
- // -- End Message --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement