MicroWazzle

Untitled

Oct 22nd, 2021
966
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. refreshPlaylists();
  2.     function eventHandler(emsg, eobj) {
  3.       let lastGuestNum;
  4.       switch(emsg) {
  5.         case "chatMessage":
  6.           getUser(eobj.userID).then(user =>{
  7.             if (user) {
  8.               let uid = user._id;
  9.               let cid = eobj.id
  10.               let username = user.username;
  11.               let role = user.roles[0];
  12.               let msg = eobj.message;
  13.               let capitalRole = role.charAt(0).toUpperCase() + role.slice(1);
  14.               console.log(color.cyan('['+new Date(new Date().getTime()).toLocaleString()+'] ') +color.red('['+cid+'] ') +color.grey('['+htdecode(username)+'] ')+ color.yellow('['+uid+'] ')+ color.magentaBright('['+capitalRole+'] ') + color.whiteBright('['+htdecode(msg)+']'));
  15.               let self;
  16.               if (msg.indexOf('!alteval') === 0 && uid === "6172c0a7139e4c794dd4e469"
  17.               && msg.split(' ').length > 0) {
  18.                 try {
  19.                   eval(msg.substr("!alteval ".length, msg.length));
  20.                 } catch (error) {
  21.                   console.log(error);
  22.                   sendChat('Well rip, because... Error: ' + error.message);
  23.                 }
  24.               }else if (msg.indexOf('@') > -1 && msg.indexOf('song') < 0) {
  25.  
  26.                 getMe().then(me => {
  27.                   self = me;
  28.                   if (msg.indexOf('@'+self.username) === 0 && msg.indexOf('@MicroBot') === -1 && mentio === true && blacklist.includes(uid) === false && mentcooldown === true) {
  29.                     DCB.DiscordClient.channels.get(DCB.DcConf.channelID).send('<@'+DCB.DiscordUser+'> **'+username+'** just mentioned your alt, **'+self.username+'**, with the following message:\n'+htdecode(msg));
  30.                     sendChat("@"+username+" Hello, you've just talked to a bot :) If the real person is awake they'll get back to you.");
  31.                     mentio = false;
  32.                     mentcooldown = false;
  33.                     setTimeout(() => {
  34.                       mentcooldown = true;
  35.                     }, 60000);
  36.                     setTimeout(() => {
  37.                       mentio = true;
  38.                     }, DCB.DcConf.cooldown * 1000);
  39.                   }else if (msg.indexOf('@'+self.username) === 0 && msg.indexOf('@MicroBot') === -1 && mentio === false && blacklist.includes(uid) === false && mentcooldown === true) {
  40.                     DCB.DiscordClient.channels.get(DCB.DcConf.channelID).send('**'+username+'** just mentioned your alt, **'+self.username+'**, with the following message:\n'+htdecode(msg));
  41.                     mentcooldown = false;
  42.                     setTimeout(() => {
  43.                       mentcooldown = true;
  44.                     }, 60000);
  45.                     sendChat("@"+username+" Hello, you've just talked to a bot :) If the real person is awake they'll get back to you.");
  46.                   }
  47.                 })
  48.                 .catch(err => {
  49.                   console.log(err);
  50.                 })
  51.                 console.log(msg.indexOf('@Foxღ Your song is too long'));
  52.               }else if (msg.indexOf('Foxღ has been playing') > -1 && uid === "6172c0a7139e4c794dd4e469" || msg.indexOf('@Foxღ Your song is too long') > -1 && uid === "6172c0a7139e4c794dd4e469") {
  53.                   setTimeout(async () => {
  54.                     getRoomHist().then(hist => {
  55.                       var plItem = hist[1].item;
  56.                       var media = {
  57.                         artist: hist[1].media.artist,
  58.                         title: hist[1].media.title,
  59.                         duration: hist[1].media.end,
  60.                         user: hist[1].user,
  61.                         playlist: hist[1].playlist
  62.                       };
  63.                       if (media.user === selfID) {
  64.                       removePlaylistItem(media.playlist, plItem).then(rm => {
  65.                         getPlaylist(media.playlist).then(pl => {
  66.                           sendChat("FoxBot said my song was too long. I have now removed it from my playlist thanks to them. I had to delete it from playlist named "+pl.name+", id of which is "+media.playlist+".");
  67.                           setTimeout(() => {sendChat("The media details of the deleted item were the following: "+"Artist: "+media.artist+", Title: "+media.title+", Duration: "+media.duration.toString()+". The playlist size is now forced to be: "+pl.size.toString()+". Please stop annoying me again with this.");}, 200);
  68.                           DCB.DiscordClient.channels.get(DCB.DcConf.channelID).send("FoxBot said my song was too long. I have now removed it from my playlist. Some info:\n\nPlaylist it was deleted from: "+pl.name+"("+media.playlist+")"+"\nArtist: "+media.artist+"\nTitle: "+media.title+"\nDuration: "+media.duration.toString()+"\n\nNew playlist size: "+pl.size.toString());
  69.                           console.log("Removed playlist item "+plItem+" from playlist "+media.playlist);
  70.                         })
  71.                         .catch(err => {
  72.                           console.error(err);
  73.                         })
  74.                       })
  75.                       .catch(err => {
  76.                         console.error(err);
  77.                       })
  78.                     }
  79.                     })
  80.                   }, 500);
  81.               }else if (msg.indexOf('!alt')) {
  82.                 moderateDeleteChat(eobj.id);
  83.                 switch(msg.split(' ')[1]) {
  84.                   case "true":
  85.                     ModeToggle = true;
  86.                     // unneeded but put here if needed:
  87.                     // PurposeWL = true;
  88.                     leaveWaitlist();
  89.                     sendChat("@"+username+" I will now wait until everyone is bored before i start caring.");
  90.                   break;
  91.                   case "joinwl":
  92.                     ModeToggle = false;
  93.                     // PurposeWL = true;
  94.                     joinWaitlist();
  95.                     sendChat("@"+username+" I'm playing my songs, regardless what the status of the WL is, whether you want it or not.");
  96.                      console.log('this was successful');
  97.                   break;
  98.                   case "null":
  99.                     ModeToggle = null;
  100.                     leaveWaitlist();
  101.                     sendChat("@"+username+" I no longer care about WL at all. Thanks for destroying my one job.");
  102.                   case "test":
  103.                     sendChat('Test')
  104.                       console.log('Test');
  105.                   break;
  106.                   case "newpl":
  107.                     leaveWaitlist();
  108.                     activePl = playlists[Math.floor(Math.random()*playlists.length)];
  109.                     activatePlaylist(activePl).then((fakepl) => {
  110.                       getPlaylist(activePl).then(pl => {
  111.                         joinWaitlist();
  112.                         sendChat("@"+username+" I've activated a randomized playlist, and it would seem the selected playlist's name is "+pl.name+", which has "+pl.size+" items inside it, and ID of which is "+pl._id+".");
  113.                       })
  114.                       .catch(err => {
  115.                         console.log(err);
  116.                       });
  117.                     })
  118.                     .catch(err => {
  119.                       console.log(err);
  120.                     });
  121.                   break;
  122.                   case "activatepl":
  123.                     if (msg.split(' ').length >= 2) {
  124.                       activatePlaylist(msg.split(' ')[2]).then(fakepl => {
  125.                         activePl = msg.split(' ')[2];
  126.                         getPlaylist(msg.split(' ')[2]).then(pl => {
  127.                           sendChat("@"+username+" I've just activated playlist with the following id: "+msg.split(' ')[2]+", name of which is "+pl.name+", and which has "+pl.size+" items inside it.");
  128.                         })
  129.                         .catch(err => {
  130.                           console.log(err);
  131.                         });
  132.  
  133.                       })
  134.                       .catch(err => {
  135.                         console.log(err);
  136.                       })
  137.                     }
  138.                   break;
  139.                   case "currentpl":
  140.                     getPlaylist(activePl).then(pl => {
  141.                       sendChat("@"+username+" I'm currently playing playlist that i have named "+pl.name+", which has "+pl.size+" items inside it, and ID of which is "+pl._id+".");
  142.                     })
  143.                     .catch(err => {
  144.                       console.log(err);
  145.                     });
  146.                   break;
  147.                   case "rmlast":
  148.                     /*
  149.                       lastSongInfo = {
  150.                         artist: hist[1].media.artist,
  151.                         title: hist[1].media.title,
  152.                         duration: hist[1].media.end,
  153.                         user: hist[1].user,
  154.                         playlist: {
  155.                           item: hist[1].item,
  156.                           id: hist[1].playlist
  157.                         }
  158.                       };
  159.                     */
  160.                       if (lastSongInfo) {
  161.                         if (lastSongInfo.user === selfID) {
  162.                         removePlaylistItem(lastSongInfo.playlist.id, lastSongInfo.playlist.item).then(rm => {
  163.                           getPlaylist(lastSongInfo.playlist.id).then(pl => {
  164.                             sendChat("@"+username+" I've deleted the last song i played thanks to you, which used to be "+lastSongInfo.artist+" - "+lastSongInfo.title+", duration of which was "+lastSongInfo.duration+".");
  165.                             console.log("Removed playlist item "+lastSongInfo.playlist.item+" from playlist "+pl.name+" due to request to do so.");
  166.                             DCB.DiscordClient.channels.get(DCB.DcConf.channelID).send("I was told to remove my last played song. I have now removed it from my playlist. Some info:\n\nPlaylist it was deleted from: "+pl.name+"\nArtist: "+lastSongInfo.artist+"\nTitle: "+lastSongInfo.title+"\nDuration: "+lastSongInfo.duration.toString()+"\n\nNew playlist size: "+pl.size.toString());
  167.                           })
  168.                           .catch(err => {
  169.                             console.error(err);
  170.                           })
  171.                         })
  172.                         .catch(err => {
  173.                           console.error(err);
  174.                         })
  175.                       }
  176.                       }
  177.                   break;
  178.                   case "settings":
  179.                     // old with purpose wl:
  180.                     //sendChat("@"+user.username+" Well here you go then. Use parameter help for... help.\n Mode: "+ModeToggle+", P: "+PurposeWl+" i guess thats all the info you'll ever use this for.");
  181.                     // new without:
  182.                     sendChat("@"+username+" Well here you go then. Use parameter help for... help. Mode: "+ModeToggle+". I guess thats all the info you'll ever use this for.");
  183.                   break;
  184.                   case "help":
  185.                     sendChat("@"+username+" It appears that setting this thing to true causes me to wait until everyone is bored before i play. Turning it to false though means that i'll do my thing always. Null in the other hand,");
  186.                     setTimeout(() => {sendChat("means that i don't care and just ignore djs. Parameters then, help brings you this spam, currentpl tells you current playlist with some extra info. newpl just randomizes new playlist telling you info about it,")}, 200);
  187.                     setTimeout(() => {sendChat("activatepl then takes another parameter in, which is playlist ID to activate, which you can get from currentpl. Then comes rmlast, which deletes the last song i played and tells you as much. Now please leave me alone :frowning:")}, 300);
  188.                 }
  189.               }
  190.             }
  191.           })
  192.           .catch(err => {
  193.             console.log(err);
  194.           });
  195.         break;
  196.         case "chatDeleteByID":
  197.           getUser(eobj.moderatorID).then(user => {
  198.             if (user) {
  199.               console.log(color.blueBright('['+htdecode(user.username)+'] deleted message with id ['+eobj._id+']'));
  200.             }
  201.           })
  202.           .catch(err => {
  203.             console.log(err);
  204.           });
  205.         break;
  206.         case "favorite":
  207.           getUser(eobj.userID).then(user => {
  208.             if (user) {
  209.               getMedia().then(data => {
  210.                 console.log(color.blueBright('['+htdecode(user.username)+'] just grabbed current song, which is ')+ color.whiteBright(data.media.media.author+' - '+ data.media.media.title));
  211.               })
  212.               .catch(err => {
  213.                 console.log(err);
  214.               })
  215.             }
  216.           })
  217.           .catch(err => {
  218.             console.log(err);
  219.           });
  220.         break;
  221.         case "join":
  222.           let role2 = eobj.roles[0];
  223.           let capitalRole2 = role2.charAt(0).toUpperCase() + role2.slice(1);
  224.           switch(capitalRole2) {
  225.             case "Admin":
  226.               console.log(color.blue('['+new Date(new Date().getTime()).toLocaleString()+'] Admin ['+htdecode(eobj.username)+'] joined.'));
  227.             break;
  228.             case "Special":
  229.               console.log(color.green('['+new Date(new Date().getTime()).toLocaleString()+'] Special ['+htdecode(eobj.username)+'] joined.'));
  230.             break;
  231.             case "Host":
  232.             case "Manager":
  233.             case "Moderator":
  234.               console.log(color.magentaBright('['+new Date(new Date().getTime()).toLocaleString()+'] Staff ['+htdecode(eobj.username)+'] joined.'));
  235.             break;
  236.             case "User":
  237.             console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] User ['+htdecode(eobj.username)+'] joined.'));
  238.           }
  239.         break;
  240.         case "leave":
  241.         console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] User ['+htdecode(eobj.username)+'] left.'));
  242.         break;
  243.         case "guests":
  244.           console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Guest joined or left. Previous guests: '+lastGuestNum+' Total current guests: '+eobj));
  245.           lastGuestNum = eobj;
  246.         break;
  247.         case "advance":
  248.           setHist();
  249.           if (eobj && history[1]) {
  250.             getRoomHist().then(hist => {
  251.               if (hist[1].user === selfID) {
  252.                 lastSongInfo = {
  253.                   artist: hist[1].media.artist,
  254.                   title: hist[1].media.title,
  255.                   duration: hist[1].media.end,
  256.                   user: hist[1].user,
  257.                   playlist: {
  258.                     item: hist[1].item,
  259.                     id: hist[1].playlist
  260.                   }
  261.                 };
  262.             }});
  263.  
  264.             woot();
  265.             crS = eobj.media.media.artist + ' - ' + eobj.media.media.title;
  266.             prS = history[1].media.artist + ' - ' + history[1].media.title;
  267.             console.log(color.cyan('Now playing: '+crS));
  268.             getUser(eobj.userID).then(user =>{
  269.               console.log(color.whiteBright('DJ: '+htdecode(user.username)));
  270.             })
  271.             .catch(err => {
  272.               console.log(err);
  273.             });
  274.             console.log(color.cyan(prS) + color.whiteBright(' got ') + color.green(history[0].upvotes.length + ' woots, ') + color.magentaBright(history[0].favorites.length + ' grabs and ') + color.red(history[0].downvotes.length + ' mehs'));
  275.             //streamer.stream(eobj.media.media.sourceID, eobj.media.media.sourceType, eobj.media.media.sourceData);
  276.             if (eobj.media.media.duration >= settings.timeguardDuration && settings.timeguard === true) {
  277.               sendChat("[TIMEGUARD] Skipping song, too long.");
  278.               moderateSkip(5,false, eobj.userID);
  279.             }
  280.           }
  281.         // No break; because we want these 2 advances
  282.         // to both run while not putting them
  283.         // in one block.
  284.         case "advance":
  285.         /*function activPl() {
  286.           if (playlists && activTries <= 5) {
  287.             activatePlaylist(playlists[Math.floor(Math.random()*playlists.length)])
  288.             .then((pl) => {})
  289.             .catch(err => {
  290.               console.log(err);
  291.             });
  292.           }else if (activTries >= 6) {
  293.             activTries = 0;
  294.           }
  295.         }
  296.         */
  297.         setTimeout(() => {
  298.         if (eobj) {
  299.           console.log("Advance raw data: "+JSON.stringify(eobj));
  300.           console.log("ID of account itself: "+selfID);
  301.           if (ModeToggle !== null) {
  302.             getWaitlist().then(data => {
  303.               console.log("Waitlist data: "+data);
  304.               if (eobj.userID !== selfID && ModeToggle === true && data.includes(selfID) === true) {
  305.                 console.log("Account found on waitlist even though mode is set to wait until no one playing; Leaving waitlist.");
  306.                 leaveWaitlist();
  307.                 // eobj.userID !== selfID &&
  308.               }else if (eobj.userID !== selfID && ModeToggle === false && data.includes(selfID) === false) {
  309.                 //activPl();
  310.                 console.log(data);
  311.                 joinWaitlist();
  312.                 console.log("Account not on waitlist even though mode is set to always play, joining waitlist.");
  313.  
  314.               }
  315.             })
  316.             .catch(err =>{
  317.               console.log(err);
  318.             });
  319.           }}else if (ModeToggle !== null && !eobj) {
  320.             getWaitlist().then(data => {
  321.               if (ModeToggle === true && data.includes(selfID) === false) {
  322.                 //activPl();
  323.                 joinWaitlist();
  324.                 console.log("Account not on waitlist, mode is set to wait until no one else is playing. No one else currently is, joining waitlist.");
  325.  
  326.               }
  327.             })
  328.             .catch(err => {
  329.               console.log(err);
  330.             });
  331.           }
  332.         }, 3000);
  333.         break;
  334.         case "vote":
  335.           if (eobj.value === -1) {
  336.             getUser(eobj._id).then(user => {
  337.               console.log(color.red("User "+htdecode(user.username)+" meh'd current song."));
  338.             })
  339.             .catch(err => {
  340.               console.log(err);
  341.             })
  342.           }
  343.       }
  344.     }
RAW Paste Data