Advertisement
AEAEAEAEarray

bro bot

Oct 2nd, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const send = MPP.chat.send;
  2. const PREFIX = "@";
  3. const PREFIX_LENGTH = PREFIX.length;
  4. MPP.client.on('a', function (msg) {
  5.     // if user switches to VPN, these need to update
  6.     var yourParticipant = MPP.client.getOwnParticipant();
  7.     var yourId = yourParticipant._id;
  8.     var yourUsername = yourParticipant.name;
  9.     var username = msg.p.name;
  10.     var userId = msg.p.id;
  11.     var usercolor = msg.p.color;
  12.     // get the message as string
  13.     var input = msg.a.trim();
  14.     var request = msg.a.split(' ')[0];
  15.     // evaluate input into command and possible arguments
  16.     var message = input.substring(PREFIX_LENGTH).trim();
  17.     var hasArgs = message.indexOf(' ');
  18.     var command = (hasArgs != -1) ? message.substring(0, hasArgs) : message;
  19.     var argumentsString = (hasArgs != -1) ? message.substring(hasArgs + 1).trim() : null;
  20.     var args = msg.a.match(/\w+/g);
  21.     // look through commands
  22.     var isBotOwner = userId === yourId;
  23.     switch (request.toLowerCase()) {
  24.         case PREFIX+"help": help(argumentsString); break;
  25.         case PREFIX+"say": say(argumentsString); break;
  26.         case PREFIX+"rev": case PREFIX+"reverse": reverse(argumentsString); break;
  27.         case PREFIX+"about": about(); break;
  28.         case PREFIX+"ban": ban(userId, yourId, args); break;
  29.         case PREFIX+"8ball": case PREFIX+"8": ball(argumentsString); break;
  30.         case PREFIX+"coinflip": case PREFIX+"cf": coin(username); break;
  31.     }
  32. })
  33.  
  34. const cmd = [
  35.     ["help", "Shows command of this bot, type help [command name] for more info"],
  36.     ["say", "This command say your message. just for fun"],
  37.     ["reverse", "this command reverse your text"],
  38.     ["about", "about this bot"],
  39.     ["ban", "if you are crown. you can ban anyone using this command"],
  40.     ["8ball", "This is magic 8ball! it can ans your question"],
  41.     ["coinflip", "flip a coin"]
  42. ]
  43.  
  44. function getcmdinfo(cm, index) {
  45.     return `Command name: ${cm}, About this command: ${cmd[index][1]}`;
  46. }
  47.  
  48. function help(info) {
  49.     if (!info) {
  50.         send(`Useful: ${PREFIX}${cmd[0][0]} [command], ${PREFIX}${cmd[1][0]}, ${PREFIX}${cmd[2][0]}, ${PREFIX}${cmd[3][0]}, ${PREFIX}${cmd[4][0]}, ${PREFIX}${cmd[5][0]}, ${PREFIX}${cmd[6][0]}`);
  51.     } else {
  52.         switch (info.toLowerCase()) {
  53.             case "help":
  54.                 send(getcmdinfo("help", 0));
  55.                 break;
  56.             case "say":
  57.                 send(getcmdinfo("say", 1));
  58.                 break;
  59.             case "reverse": case "rev":
  60.                 send(getcmdinfo("reverse", 2));
  61.                 break;
  62.             case "about":
  63.                 send(getcmdinfo("about", 3));
  64.                 break;
  65.             case "ban":
  66.                 send(getcmdinfo(info, 4));
  67.                 break;
  68.             case "8ball": case "8":
  69.                 send(getcmdinfo("8ball", 5));
  70.                 break;
  71.             case "coinflip": case "cf":
  72.                 send(getcmdinfo("coinflip", 6));
  73.             default:
  74.                 send("Invalid command! '" + info + "' command dosn't exsits");
  75.                 break;
  76.         }
  77.     }
  78. }
  79.  
  80. function say(input) {
  81.     if (!input) return send("Please enter a message to say! usage: " + PREFIX + "say [text]");
  82.     send("Say: " + input);
  83. }
  84.  
  85. function reverse(input) {
  86.     if (!input) return send("Please enter a text to reverse! usage: " + PREFIX + "reverse [text]");
  87.     let revtext = input.split('').reverse().join('');
  88.     if (revtext === input) return send("❎Can't reverse same word!");
  89.     send("Reversed: " + revtext);
  90. }
  91.  
  92. function about() {
  93.     send("Made by BRO 67");
  94.     send("Customized by Anonydiamond");
  95. }
  96.  
  97. function ban(user, u, args) {
  98.     if (user !== u) return send("You don't have any permission to use this command");
  99.     if (u !== MPP.client.channel.crown.userId) return send("You are not the crown");
  100.     if (!args[1] || !args[2]) return send("Please enter a user full id ban. ban requires user full id! Usage: " + PREFIX + "ban [minute] [userid]");
  101.     let min = args[1] * 60000;
  102.     let idtoban = args[2];
  103.     let users = MPP.client.ppl[idtoban].id;
  104.     try {
  105.         MPP.client.sendArray([{ m: "kickban", _id: users, ms: min }]);
  106.     } catch (err) {
  107.         send("Unknown user");
  108.     }
  109. }
  110.  
  111. function ball(input) {
  112.     if (!input) return send("Please ask a question to 8 ball. Usage: 8ball [question]");
  113.     let replays = ["yes", "Outlook seems good", "yus", "of course", "Yes - definitely", "no", "Better not tell you now.", "Outlook is not so good..", "nah", "never", "Cannot predict now.", "I dont know.", "I dont know *yet*..", "not a chance", "I think so.", "only for today!", "not for today", "sadly..yes", "sadly no..", "maybe", "ask againlater.."];
  114.     let replay = replays[Math.floor(Math.random() * replays.length)];
  115.     send(`🎱 ${replay}`);
  116. }
  117.  
  118. function coin(name) {
  119.     let lucks = ["heads", "tails"];
  120.     let luck = lucks[Math.floor(Math.random() * lucks.length)];
  121.     send(`${name} flip a coin! get ready`);
  122.     setTimeout(()=>{
  123.         send("It was " + luck);
  124.     }, 3000)
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement