How To Stay Online On Discord 24/7 ⭐

Pop this into a node.js REPL and attach a pinger to it, and you can have your discord account online 24/7 if you want that for some reason :slight_smile:

const { exec } = require("child_process");

const clearPorts = (ports) => {
  const promises = ports.map((port) => {
    return new Promise((resolve, reject) => {
      const command = `lsof -i :${port} | grep LISTEN | awk '{print $2}'`;
      const child = exec(command, (error, stdout, stderr) => {
        if (error) {
          reject(error);
        } else {
          if (stdout) {
            const pid = stdout.trim();
            exec(`kill ${pid}`, (error, stdout, stderr) => {
              if (error) {
                reject(error);
              } else {
                resolve();
              }
            });
          } else {
            resolve();
          }
        }
      });
    });
  });
  return Promise.all(promises);
};


// Clear the ports
clearPorts([3000, 3001]).then(() => {
  console.log("Ports cleared!");
  const Eris = require("eris");
  const express = require("express");
  
  // Create an array of bot objects, each representing a different Discord account
  const bots = [
    new Eris(process.env.TOKEN_1),
    new Eris(process.env.TOKEN_2),
  ];
  
  // Connect each bot to Discord
  bots.forEach((bot) => {
    bot.connect();
  });
  
  // Create a keepAlive function for each bot object
  function keepAlive(bot, index, port) {
    const server = express();
  
    server.all("/", (req, res) => {
      res.send("502Development Account Onliner Active");
    });
  
    server.listen(port, () => {
      console.log(`Server for bot ${index} is ready on port ${port}!`);
    });
  }
  
  bots.forEach((bot, index) => {
    keepAlive(bot, index, 3000 + index);
  });
});

Enjoy!

3 Likes