Skip to content

Instantly share code, notes, and snippets.

@justbill2020
Created December 21, 2016 02:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justbill2020/0c4b43b578f36a8943d7176d30e8fc0c to your computer and use it in GitHub Desktop.
Save justbill2020/0c4b43b578f36a8943d7176d30e8fc0c to your computer and use it in GitHub Desktop.
Delete All Messages in a channel on discord
;(function(){
	const authToken = JSON.parse(localStorage.token);
	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 + '?limit=100', {headers})
		.then(resp => resp.json())
		.then(messages => {
		return Promise.all(messages.map((message) => {
			return delay(clock += interval).then(() => fetch(`${baseURL}/${message.id}`, {headers, method: 'DELETE'}));
		}));
	}).then(() => console.log("Done!"));
}());

All you have to do is open a browser, like chrome, open discord and open the channel you want to delete all messages from. Then open the dev tools (ctrl + shift + i in chrome) and paste this into the console window of the dev tools. Then press enter... after it delete all it can see up to 100 messages you'll have to click load more messages and then run it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment