-
-
Save billpliske/98f1d1b07b58d473ab1963856f3e2f45 to your computer and use it in GitHub Desktop.
slack-delete-files.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteFiles(types = 'all') { | |
let files = []; | |
function deleteFilesByTypes(types, page = 1) { | |
TS.api.call('files.list', { | |
types, | |
user: boot_data.user_id, | |
page | |
}, (a, data) => { | |
files = [...files, ...data.files]; | |
if (data.paging.page !== Math.ceil(data.paging.total / data.paging.count)) { | |
deleteFilesByTypes(types, data.paging.page + 1); | |
} else { | |
files.forEach(file => | |
TS.api.call('files.delete', { | |
file: file.id | |
}, () => | |
console.log('Файл удалён: ' + file.name) | |
) | |
); | |
} | |
}); | |
}; | |
deleteFilesByTypes(types); | |
}; | |
deleteFiles(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment