title: Using clearInterval while setInterval runs
body: <p>Fairly new to using JS, and was trying to create a Discord bot that that takes a JSON array, randomly chooses 1 value from the correlating key, and automatically outputs it every 24 hours (basically a quote of the day bot). </p>
  
  <p>I'm currently using <code>setInterval</code> to do this, however, I'm not able to <code>clearInterval</code> while it runs, leaving me to <code>ctrl + C</code> the PowerShell. </p>
  
  <pre><code>client.on('message', function(message) {
  
  if(message.author.bot) return;
  
  if(message.content.indexOf(config.prefix) !== 0) return;
  
  const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  
  if (command === "qotd") 
  { 
  const intervalSet = args.join(" ")
  message.channel.send(randomQuestion())
      var interval = setInterval (function () 
      {
          //randomQuestion() is the function that returns the randomly selected value
          //message.channel.send(randomQuestion()) is there twice so it runs once 
          //before the timer starts (otherwise it'll take x time to output once
          message.channel.send(randomQuestion())
          .catch(console.error) // add error handling here
          return interval;
      }, intervalSet); 
  
  }
  
  if (command === "stopqotd")
  {
      clearInterval(interval);
  }
  });
  </code></pre>
  
  <p>I have tried putting another command with <code>clearInterval(interval)</code> in the same <code>client.on()</code> and in a separate one, both don't stop it. </p>
  
  <p>The ONLY reason it needs to stop is to add/remove quotes. Otherwise, it can just run endlessly.</p>
  
  <p>Any suggestions?</p>