issue with lockdown command

let data = await db.findOne({ guild: message.guild.id }).catch(err => { })
if(data.lockdown === true) { message.channel.send({embeds: [errEmbed]}).then(a => {
  setTimeout(() => { message.delete(), a.delete() }, 3000)
})
}

else if(!data) {
  let data2 = new db({

    guild: message.guild.id,
    lockdown: true
  
  }) 
  
  await data2.save()
  } else {
  db.findOneAndUpdate({ guild: message.guild.id }, { lockdown: true }).catch(err => { })
  }


why is this returning this on the console

if(data.lockdown === true) { message.channel.send({embeds: [errEmbed]}).then(a => {
        ^

TypeError: Cannot read properties of null (reading 'lockdown')
    at Object.run (C:\Users\cmart\Desktop\discord.js\Commands\Moderation\lockdown.js:15:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Was this page helpful?