Advertisement
Alexquickdraw

[Discord] Alert when a user goes online in a server

Nov 5th, 2020
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This script will alert you with text to speech
  3. when a target user is goes online inside your discord server.
  4. */
  5.  
  6. var alert_flags = [];
  7.  
  8. const targets = {
  9.     "ᴶᵉˢˢ": {
  10.         "tts_msg": "Jessica is active."
  11.     },
  12.     "Twink": {
  13.         "tts_msg": "Jadie has active."
  14.     }
  15. };
  16.  
  17.  
  18. function getNames() {
  19.     var names = [];
  20.     const collection = document.getElementsByClassName("name-uJV0GL");
  21.     for (x = 0; x < collection.length; x++) {
  22.         names.push(collection[x].textContent);
  23.     }
  24.     return names;
  25. }
  26.  
  27.  
  28. setInterval(function() {
  29.     for (t = 0; t < Object.keys(targets).length; t++) {
  30.         if (!alert_flags.includes(Object.keys(targets)[t])) {
  31.             if (getNames().includes(Object.keys(targets)[t])) {
  32.                 alert_flags.push(Object.keys(targets)[t]);
  33.                 var tts_alert = new SpeechSynthesisUtterance(targets[Object.keys(targets)[t]]["tts_msg"]);
  34.                 window.speechSynthesis.speak(tts_alert);
  35.  
  36.             }
  37.         }
  38.     }
  39.     for (y = 0; y < alert_flags.length; y++) {
  40.         if (!getNames().includes(alert_flags[y])) {
  41.             alert_flags.pop(alert_flags[y]);
  42.         }
  43.     }
  44. }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement