title: How to fix 'Cannot read property 'id' of 'null'
body: <p>I have this error message that comes in from time to time that crashes my bot.<br>
  Here is the error message in the console:</p>
  
  <pre class="lang-none prettyprint-override"><code>C:\Users\Administrator\Desktop\FortniteRanked8.5\events\message.js:7
    if(prefixed.hasOwn(message.guild.id)){
                                     ^
  
  TypeError: Cannot read property 'id' of null
      at module.exports (C:\Users\Administrator\Desktop\FortniteRanked8.5\events\message.js:7:36)
  </code></pre>
  
  <p>The problem comes from this line:</p>
  
  <pre><code>if (prefixes.hasOwn(message.guild.id)){
  </code></pre>
  
  <p>Setup:</p>
  
  <ul>
  <li>Windows server 2012</li>
  <li>Discord.js : v11.4.2</li>
  <li>node : v8.11.1</li>
  </ul>
  
  <p>Code:</p>
  
  <pre><code>const Store = require('data-store');
  
  module.exports = (client, message) =&gt; {
    var prefixes = new Store({ path: __dirname + '/../prefixes.json' });
    // console.log(prefixes.clone())
  
    if (message.author.bot) return;
  
    var prefix = client.config.prefix
  
    if (prefixes.hasOwn(message.guild.id)){
      prefix = prefixes.get(message.guild.id)
    }
  
    if (message.content.indexOf(prefix) !== 0) return;
  
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();
    const cmd = client.commands.get(command);
  
    if (!cmd) return;
  
    if (cmd &amp;&amp; !message.guild)
      return message.channel.send("Vous ne pouvez pas faire de commande ici, Merci de faire les commandes directement sur votre serveur discord.");
  
    cmd.run(client, message, args);
  };
  </code></pre>