我想检查用户(chat.chatid)是否已经在数组(ids.json)中,否则将其添加到该数组中。为此,我正在使用“包含”
//chat.chatid = 469750202
//owner(Property) = { users: ["469750202", "638606486"] }
var ids = Bot.getProperty('owner')
if (!ids) {
var ids = {
users: []
}
};
if (!ids.users.includes(chat.chatid)) {
ids.users.push(chat.chatid);
Bot.setProperty("owner", ids, "json");
};
Bot.sendMessage('some text');
答案 0 :(得分:0)
您需要验证您的ids
确实有价值:
{用户:[“ 469750202”,“ 638606486”]}
尝试运行:
var ids = Bot.getProperty('owner');
Bot.sendMessage( JSON.stringfy(ids) );
有可能 ids.users未定义