title: Outside JavaScript function returning an error when used inside another function
body: <p>I have a Discord bot that I'm trying to make update a database when an event triggers. However, inside of the actual event code, no outside functions are running</p>
  
  <p>Function(s) I'm trying to run:</p>
  
  <pre class="lang-js prettyprint-override"><code>async log(text, type) {
    if (!type) console.log(`${Chalk.bgGreen(new Date().toUTCString())} ${text}`);
    if (type == 'warn') console.log(`${Chalk.bgYellow(new Date().toUTCString())} ${text}`);
    if (type == 'error') console.log(`${Chalk.bgRed(new Date().toUTCString())} ${text}`);
    if (type == 'cmd') console.log(`${Chalk.bgBlue(new Date().toUTCString())} ${text}`);
    if (type == 'db') console.log(`${Chalk.bgMagenta(new Date().toUTCString())} ${text}`);
  }
  </code></pre>
  
  <pre><code>var d = this.client.data.load()
  console.log(d)
  </code></pre>
  
  <p>The function where I'm running my code:</p>
  
  <pre class="lang-js prettyprint-override"><code>const filter = (reaction, user) =&gt; {
    console.log(user);
    return reaction.emoji.name === "" &amp;&amp; user.bot === false;
  };
  
  let collector = message.createReactionCollector(filter, {
    time: 60000,
    max: 2
  });
  
  collector.on('collect', async (reaction, collector) =&gt; {
    var d = this.client.data.load()
    console.log(d)
    message.delete();
    this.log('Database updated', 'db')
  });
  </code></pre>
  
  <p>I'm also trying to access my log function (usually accessed at <code>this.log()</code>, however it's still returning an error).</p>
  
  <p>I've gotten a multitude of errors, including the log not being able to be accessed, etc. I tried awaiting/asyncing the function as well and that didn't work either.</p>
  
  <p>I believe this is an error with JavaScript and how scope works, however any assistance would be appreciated.</p>