Created
November 10, 2015 03:32
-
-
Save WanderingHogan/3c865790982b9132157d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //you need to log in to slack here: https://api.slack.com/methods/files.list/test | |
| // generate a required token for your team | |
| // select your username | |
| // click 'test method' | |
| // take note of the 'token' and 'user' url params in the example and update the script below | |
| // this script works with node 4.1. before running, `npm i -g request` | |
| // run it with the harmony flag - ex `node --harmony scriptname.js | |
| // give it a few seconds in between running this script. The api is a bit slow and will take a few seconds to allow you to submit more requests | |
| var request = require('request'); | |
| var https = require('https'); | |
| var slackID = `abcd-####-####-####-#a#a`; | |
| var user = `ALPHANUMERIC` | |
| request.get(`https://slack.com/api/files.list?token=${slackID}&user=${user}&pretty=1`, function (error, response, content) { | |
| if (!error) { | |
| var slackFiles = JSON.parse(content).files; | |
| for( var i in slackFiles){ | |
| request.post(`https://slack.com/api/files.delete?token=${slackID}&file=${slackFiles[i].id}&pretty=1`, function (error, response, content) { | |
| if (!error) { | |
| console.log(slackFiles[i].id, content); | |
| }; | |
| }); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment