-
Notifications
You must be signed in to change notification settings - Fork 0
/
script
26 lines (23 loc) · 928 Bytes
/
script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var before = REMOVE_THIS_AND_CHANGE_TO_LAST_MESSAGE_ID_THAT_YOU_SENT_IN_THE_CONVERSATION;
clearMessages = function(){
const authToken = "PASTE_YOUR_TOKEN_INSIDE_THESE_QUOTATION_MARKS_BUT_DON'T_PASTE_WITH_ANY_QUOTATION_MARKS";
const channel = window.location.href.split('/').pop();
const baseURL = `https://discordapp.com/api/channels/${channel}/messages`;
const headers = {"Authorization": authToken };
let clock = 0;
let interval = 500;
function delay(duration) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), duration);
});
}
fetch(baseURL + '?before=' + before + '&limit=100', {headers})
.then(resp => resp.json())
.then(messages => {
return Promise.all(messages.map((message) => {
before = message.id;
return delay(clock += interval).then(() => fetch(`${baseURL}/${message.id}`, {headers, method: 'DELETE'}));
}));
}).then(() => clearMessages());
}
clearMessages();