Skip to content

Instantly share code, notes, and snippets.

@kaisugi
Created November 15, 2018 18:00
Show Gist options
  • Save kaisugi/91d6fb7247582a30a006c416aaef9c08 to your computer and use it in GitHub Desktop.
Save kaisugi/91d6fb7247582a30a006c416aaef9c08 to your computer and use it in GitHub Desktop.
Mastodon消すやつ
const ACCESS_TOKEN =
"hogehogehogehoge";
const Masto = require("mastodon");
const M = new Masto({
access_token: `${ACCESS_TOKEN}`,
api_url: "https://mstdn.jp/api/v1/"
});
M.get("accounts/verify_credentials").then(res => {
const user_id = res.data.id;
console.log(res.data.statuses_count);
M.get(`accounts/${user_id}/statuses`, { limit: 40 })
.then(res => {
const tootData = res.data;
const promiseList = []
tootData.forEach(toot => {
const toot_id = toot.id;
promiseList.push(delete_toot(toot_id));
});
Promise.all(promiseList).then(console.log("fin!"));
})
.catch(err => {
console.log(err);
process.exit(1);
});
});
function delete_toot(toot_id) {
return new Promise((resolve, reject) => {
M.delete(`statuses/${toot_id}`).then(() => {
resolve()
}).catch(err => reject(err));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment