Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
slack-delete-files.js
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();
@felixexter

This comment has been minimized.

Copy link
Owner Author

felixexter commented Jun 6, 2016

В консоли браузера вставить код выше и нажать enter.
Если нужно удалить конкретные типы файлов, то в функцию deleteFiles() передать строку с одним типов:
all - All files (default);
spaces - Posts;
snippets - Snippets;
images - Image files;
gdocs - Google docs;
zips - Zip files;
pdfs - PDF files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.