title: ReferenceError: bot is not defined
body: <p>This is something with the const or var. I think that it won't work unless I recode it. Here is my problem:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>bot.on('ready', () =&gt; {
  ^
  
  ReferenceError: bot is not defined
      at C:\Users\Dylan\Desktop\discord bot\app.js:7:1
      at ContextifyScript.Script.runInThisContext (vm.js:50:33)
      at Object.runInThisContext (vm.js:139:38)
      at Module._compile (module.js:607:28)
      at Object.Module._extensions..js (module.js:654:10)
      at Module.load (module.js:556:32)
      at tryModuleLoad (module.js:499:12)
      at Function.Module._load (module.js:491:3)
      at Function.Module.runMain (module.js:684:10)
      at startup (bootstrap_node.js:187:16)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const Discord = require('discord');
  const bot = new Discord.Bot();
  const fs = require('fs')
  const commandsList = fs.readFileSync('Storage/commands.txt','utf8');
  });
  
  bot.on('ready', () =&gt; {
    // This event will run if the bot starts, and logs in, successfully.
    console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels.`);
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '!ping') {
       message.channel.send('pong');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '!apply') {
       message.channel.send('GOGLE STUFF');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '!server') {
       message.channel.send('LA');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '!do you know dae wae') {
       message.channel.send('Yes I know dae wae brother');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === 'do you have a bot?') {
       message.channel.send('no');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === 'who is the owner') {
       message.channel.send('FantasmicNerd, duh');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === 'can i be staff' || message.content === 'can I be staff?' || message.content === 'can i be staff?') {
       message.channel.send('Application - lalalalalala');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === 'somebody touch my spaghet') {
       message.channel.send('SOMEBODY TOUCH YOUR SPAGHET!');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === 'so how about that airline food') {
       message.channel.send('HAAHAHAHHAHAHAHHAHAHAHAHAHHAHAHHAHAHAHAHHAHAHAAHAHAHHAHAHAHHAHAHAHAHAHHAHAHHAHAHAHAHHAHA');
     }
  });
  
  bot.on('ready',() =&gt; {
      console.log('Bot Launched...')
  
      bot.user.setStatus('Online')
  
      bot.user.setActivity('on The Magical')
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '?help' || message.content === '?Help') {
       message.channel.send('I have messaged you the commands and prefix.');
     }
  });
  
  bot.on('message', message =&gt; {
      if (message.content === '?help' || message.content === '?Help') {
       message.author.sendMessage(commandsList);
     }
  });
  
  bot.on('ready', function() {
      bot.user.setUsername("The Magical");
  
  // THIS  MUST  BE  THIS  WAY
  bot.login('NDA0NjYzNzIwNDQzMzc5NzEy.DUapFw.zjDvPkG4QxZJ1rdxDYaPZEaVpiM');</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have looked all over for answers but nothing seems to work. I end up with this in <code>cmd</code> prompt when I try to run it</p>