Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bot
- const mineflayer = require("mineflayer");
- const Vec3 = require("vec3").Vec3;
- //Setup Variables
- var host = ("metoothanks.ca");
- var port = ("25565");
- var ip = (host+":"+port);
- var user = ("apt.79821@supermail.xyz");
- var pass = ("lejeff999");
- var space = (" ");
- //Setup
- var bot = mineflayer.createBot({
- host: host,
- port: port,
- username: user,
- password: pass,
- verbose: true,
- });
- //Bot Variables
- var prefix = ('?');
- var version = ('a0 Recoded');
- var admin = ('aptget_');
- //Command Variables
- var msg = ('/tell ');
- var ignore = ('/ignore ');
- //Errors
- var error = ('Error: ');
- var permissionerror = ('Not enough permissions');
- var commanderror = ('Unknown command');
- var genericerror = ('Generic error');
- var kicked = ('Kicked for');
- var argumenterror = ('Incorrect arguments');
- var cannotignore = ('Cannot ignore that player');
- //Help Variables
- var helpList = [
- " ]---[MegaBOT Commands]---[",
- " ]---[Prefix: "+prefix+"]---[",
- " ]---[Version: "+version+"]---["
- ];
- //Etc Variables
- var colon = (":");
- var motds = [
- "name jeff",
- "deez nuts",
- "i like big weener",
- "le me me"
- ]
- var blacklist = [
- "jeff"
- ]
- function updateTime() {
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var seconds = date.getSeconds();
- time = ("["+day+colon+hours+colon+minutes+colon+seconds+"] ");
- }
- setInterval(updateTime, 1000)
- var motdNum = motds[Math.floor(Math.random() * motds.length)];
- //Chat
- bot.on('chat', (username, message) => {
- var name = username.trim();
- if (!message.startsWith(prefix)) return;
- if (name === bot.username || blacklist.includes(name)) return;
- var index = message.indexOf(" ");
- if (index < 0) {
- var keyword = message.substring(prefix.length);
- var args = [];
- } else {
- var keyword = message.substring(prefix.length, index);
- var args = message.substring(index + 1).split(" & ");
- }
- console.log("Command: " + keyword);
- console.log("Arguments: " + args.join(", "));
- if (keyword === "quit") {
- doQuit(username, message);
- } else if (keyword === "motd") {
- bot.chat("MOTD: "+motdNum)
- } else if (keyword === "time") {
- doTime(username, message, args);
- } else if (bot.health === 10) {
- bot.chat("!!! Help, my health is below half! !!!")
- } else if (keyword === "ignore") {
- doIgnore(username, message, args)
- }
- function doTime(username, message, args) {
- if (args[0] === "irl") {
- bot.chat(time);
- } else if (args[0] === "minecraft") {
- bot.chat("["+bot.time.day % 24000 +"]");
- } else {
- bot.chat(msg+username+error+argumenterror)
- }
- }
- function doQuit(username, message) {
- if (name === admin) {
- bot.chat(msg+username+space+shutdown+time)
- console.log(time+shutdown);
- function runQuit() {
- bot.quit();
- }
- runQuit();
- } else {
- bot.chat(msg+username+space+error+permissionerror);
- }
- }
- function doIgnore(username, message, args) {
- if (name === admin) {
- if (args[0] === " " || args[0] === "" || args[0] === null || args[0] === undefined) {
- bot.chat(msg+username+error+argumenterror);
- console.log(time+username+"| Argument error");
- } else if (args[0] === admin) {
- bot.chat(msg+username+error+cannotignore);
- console.log(time+username+"| Cannot ignore "+args[0]);
- } else {
- bot.chat(ignore+args[0])
- bot.chat(msg+username+"I ignored "+args[0]);
- console.log(time+username+"| Ignored "+args[0]);
- }
- } else {
- bot.chat(msg+username+error+permissionerror);
- console.log(time+username+"| Does not have permissions for "+ignore);
- }
- }
- })
- //Bot Events
- bot.on('kicked', (reason) => {
- console.log(time+error+kicked+` ${reason}`)
- })
- bot.on('login', (username, message) => {
- doLoginFunc();
- function doLoginFunc() {
- bot.chat(time+"MOTD: "+motdNum)
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement