Skip to content

Instantly share code, notes, and snippets.

@billpliske
Forked from felixexter/slack-delete-files.js
Created May 3, 2017 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billpliske/98f1d1b07b58d473ab1963856f3e2f45 to your computer and use it in GitHub Desktop.
Save billpliske/98f1d1b07b58d473ab1963856f3e2f45 to your computer and use it in GitHub Desktop.
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment