Cannot read property 'includes' of undefined
У меня появилась проблема с кодом.
В данном коде:
const Discord = require('discord.js')
const fs = require("fs");
module.exports.run = async (bot, message, args, owners) => {
async function writeJsonOw() {
let stringData = JSON.stringify(owners)
await fs.promises.writeFile("./owners.json", stringData);
}
async function setOw(id) {
if (!owners.owner.includes(id)) {
owners.owner.push(id);
await writeJsonOw();
}
}
if(message.author.id === '690984466335662111'){
console.log( owners )
console.log( owners.owner )
console.log( typeof owners )
let id111 = args.splice(0).join(" ")
if(id111 === "" || id111 === " "){
let emb1 = new Discord.RichEmbed()
.setColor("RED")
.setTitle(`Добавление доступа к боту`)
.addField('Ошибка:','Укажите ID пользователя')
.setTimestamp()
message.channel.send( emb1 )
return
}
if(owners.owner.includes(id111)){
let emb2 = new Discord.RichEmbed()
.setColor("RED")
.setTitle(`Добавление доступа к боту`)
.addField('Ошибка: ', 'У данного человека уже есть VIP')
.setTimestamp()
message.channel.send( emb2 )
}else{
setVip(id111);
let emb3 = new Discord.RichEmbed()
.setColor('GREEN')
.setTitle(`Добавление доступа к боту`)
.addField(`Доступ выдан.`, `Юзер: <@${id111}>`)
.setTimestamp()
message.channel.send( emb3 )
}
}
}
module.exports.help = {
name: 'addowner'
}
Выводит ошибку: (node:18224) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'includes' of undefined
Содержимое JSON файла: {
"owner":[]
}
Помогите, пожалуйста! Я не понимаю в чём проблема.