title: Port binding time problem when deploying a Discord.js bot with scheduling using node-cron
body: <p>I've been trying to create a Discord bot that posts reminders at 9:00 AM and 9:00 PM everyday from March 22, 2020 to April 27, 2020.</p>
  
  <p>The scheduling process is where I initially got stuck. I  took 2 approaches:
  1. Doing it myself, using a 12hr long setInterval(), when I did that, i got an error stating that the progam failed to bind to a PORT within 60 seconds.</p>
  
  <ol start="2">
  <li>Using the node.js cron library <a href="https://github.com/kelektiv/node-cron" rel="nofollow noreferrer">https://github.com/kelektiv/node-cron</a>. But in this case the code itself didn't work the way I'd expect</li>
  </ol>
  
  <pre><code>
  
  const Discord = require('discord.js');
  const cron = require('cron')
  const client = new Discord.Client();
  
  const dolChannelID = '&lt;a working channel's id&gt;'
  let dolChannel = null
  
  const msgs = {
      'morning': 'Morning msg',
      'evening': 'Evening msg',
      'finale': 'Final msg before ending'
  }
  const startTime = new Date('March 22, 2020 9:38:00')
  const lastDate = new Date('April 27, 2020 21:00:00')
  
  // --------------------------------------------------
  
  client.on('ready', () =&gt; {
  
      console.log('we\'re up and running!')
  
      client.channels.fetch(dolChannelID)
      .then(channel =&gt; {
          dolChannel = channel
          dolChannel.send('Bot\'s working')
      })
      .then(() =&gt; {
          let execJob = new cron.CronJob('50 9,21 * * *', function() {
              let rn = new Date()
              console.log('time', rn)
              // IDEALLY HERE I'D EXPECT TO GET A CONSOLE LOG TELLING ME THE TIME twice a day, 
              // starting at 9:50 AM, but that didn't happen
              // ALTHOUGH, when my cron time expression: '* * * * * *', then things worked somehow 
              //i.e. I got an console.log every sec.
  
  
          }, null, true, 'Asia/Kolkata')
          execJob.start()
      })
      .catch((err) =&gt; {
          console.log('error \n \n', err)
      })
  })
  
  
  client.login(&lt;my secret&gt;);
  
  
  </code></pre>
  
  <p>I would appreciate any help.
  I can't seem to figure out</p>