function change(params) {
vk.call('groups.edit', {
group_id: 196543401,
screen_name: params
}).then((response) => {
console.log(response)
console.log(response.getFullResponse())
}).catch((error) => {
console.log(error);
});
}
var array = fs.readFileSync('file.txt').toString().split("\n");
for(i in array) {
console.log(array[i]);
setTimeout(function() {
change(array[i])
}, 2000);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for (let i = 0; i < 10; i++) {
console.log(i);
await sleep(500);
}
async function change(params) {
try {
const response = await vk.call("groups.edit", {
group_id: 196543401,
screen_name: params
});
console.log(response);
console.log(response.getFullResponse());
} catch (error) {
console.log(error);
}
}
const array = fs.readFileSync("file.txt").toString().split("\n");
for (const item of array) {
console.log(item);
await change(item);
await sleep(1000);
}
for (i in array){
(function (m) {
setTimeout(function () {
change(array[m])
}, 2000)
})(i)
}
function timer(ms) {
return new Promise(res => setTimeout(res, ms));
}
async function change(params) {
...
await timer(1000);
}