From 2f0bc1044172d7f9f410a15fb650fae34522da9d Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 09:44:43 -0700 Subject: [PATCH 1/8] Fix 403 --- src/undiscord-core.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index 955467f2..af8fff71 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -311,7 +311,10 @@ class UndiscordCore { let messagesToDelete = discoveredMessages; messagesToDelete = messagesToDelete.filter(msg => msg.type === 0 || (msg.type >= 6 && msg.type <= 21)); messagesToDelete = messagesToDelete.filter(msg => msg.pinned ? this.options.includePinned : true); - + + // if the user provided an author.Id, skip all messages that aren't created by the author.Id. + // fixes issues with bots & applications hanging the deletion. + if (this.options.authorId) messagesToDelete = messagesToDelete.filter(msg => msg.author.id === this.options.authorId); // custom filter of messages try { const regex = new RegExp(this.options.pattern, 'i'); From 98ac2a8a75196274a4def369c1292bc6d746930c Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 09:49:12 -0700 Subject: [PATCH 2/8] Update undiscord-core.js --- src/undiscord-core.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index af8fff71..cd5fbfa4 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -31,6 +31,7 @@ class UndiscordCore { includePinned: null, // Delete messages that are pinned pattern: null, // Only delete messages that match the regex (insensitive) searchDelay: null, // Delay each time we fetch for more messages + includeApplications: null, deleteDelay: null, // Delay between each delete operation maxAttempt: 2, // Attempts to delete a single message if it fails askForConfirmation: true, @@ -312,10 +313,12 @@ class UndiscordCore { messagesToDelete = messagesToDelete.filter(msg => msg.type === 0 || (msg.type >= 6 && msg.type <= 21)); messagesToDelete = messagesToDelete.filter(msg => msg.pinned ? this.options.includePinned : true); - // if the user provided an author.Id, skip all messages that aren't created by the author.Id. + // if the user provided an author.Id and doesn't wish to include applications, skip all messages that aren't created by the author.Id. // fixes issues with bots & applications hanging the deletion. - if (this.options.authorId) messagesToDelete = messagesToDelete.filter(msg => msg.author.id === this.options.authorId); - // custom filter of messages + if (!this.options.includeApplications) { + if (this.options.authorId) messagesToDelete = messagesToDelete.filter(msg => msg.author.id === this.options.authorId); + } + // custom filter of messages try { const regex = new RegExp(this.options.pattern, 'i'); messagesToDelete = messagesToDelete.filter(msg => regex.test(msg.content)); From 23cc4550ca4b19aa0f1049aef0d058a32c4b7adf Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 09:50:20 -0700 Subject: [PATCH 3/8] Update undiscord.html --- src/ui/undiscord.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/undiscord.html b/src/ui/undiscord.html index 455d9e70..9dc4deb5 100644 --- a/src/ui/undiscord.html +++ b/src/ui/undiscord.html @@ -103,6 +103,9 @@

Undiscord

+
+ +

From 51e034add8015e0fb208835259d85ad8ead2a0c0 Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 09:52:19 -0700 Subject: [PATCH 4/8] Update undiscord-ui.js --- src/undiscord-ui.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/undiscord-ui.js b/src/undiscord-ui.js index ec0a59b4..11839713 100644 --- a/src/undiscord-ui.js +++ b/src/undiscord-ui.js @@ -259,6 +259,7 @@ async function startAction() { const hasFile = $('input#hasFile').checked; const includePinned = $('input#includePinned').checked; const pattern = $('input#pattern').value; + const includeApplications = $('input#includeApplications').value; // message interval const minId = $('input#minId').value.trim(); const maxId = $('input#maxId').value.trim(); @@ -268,7 +269,7 @@ async function startAction() { //advanced const searchDelay = parseInt($('input#searchDelay').value.trim()); const deleteDelay = parseInt($('input#deleteDelay').value.trim()); - + // token const authToken = $('input#token').value.trim() || fillToken(); if (!authToken) return; // get token already logs an error. @@ -345,4 +346,4 @@ function stopAction() { export default initUI; -// ---- END Undiscord ---- \ No newline at end of file +// ---- END Undiscord ---- From d831bfde742f1d49f246ed67564725b82672d089 Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 10:15:27 -0700 Subject: [PATCH 5/8] Add files via upload --- src/undiscord-core.js | 11 +++++++---- src/undiscord-ui.js | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index cd5fbfa4..a81fade5 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -31,7 +31,7 @@ class UndiscordCore { includePinned: null, // Delete messages that are pinned pattern: null, // Only delete messages that match the regex (insensitive) searchDelay: null, // Delay each time we fetch for more messages - includeApplications: null, + includeApplications: null, //Include application/bot messages deleteDelay: null, // Delay between each delete operation maxAttempt: 2, // Attempts to delete a single message if it fails askForConfirmation: true, @@ -314,9 +314,12 @@ class UndiscordCore { messagesToDelete = messagesToDelete.filter(msg => msg.pinned ? this.options.includePinned : true); // if the user provided an author.Id and doesn't wish to include applications, skip all messages that aren't created by the author.Id. - // fixes issues with bots & applications hanging the deletion. - if (!this.options.includeApplications) { - if (this.options.authorId) messagesToDelete = messagesToDelete.filter(msg => msg.author.id === this.options.authorId); + // fixes issues with bots & applications hanging the deletion + if (this.options.includeApplications == false) { + log.verb("IncludeApplications filter is false. Skipping bots and applications...") + } + if (this.options.includeApplications == false) { + messagesToDelete = messagesToDelete.filter(msg => !msg.author.bot); } // custom filter of messages try { diff --git a/src/undiscord-ui.js b/src/undiscord-ui.js index 11839713..4c6eb644 100644 --- a/src/undiscord-ui.js +++ b/src/undiscord-ui.js @@ -259,7 +259,7 @@ async function startAction() { const hasFile = $('input#hasFile').checked; const includePinned = $('input#includePinned').checked; const pattern = $('input#pattern').value; - const includeApplications = $('input#includeApplications').value; + const includeApplications = $('input#includeApplications').checked; // message interval const minId = $('input#minId').value.trim(); const maxId = $('input#maxId').value.trim(); @@ -292,6 +292,7 @@ async function startAction() { content, hasLink, hasFile, + includeApplications, includeNsfw, includePinned, pattern, From 15535600ade4f1150df1680529cef30626d3bc87 Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 10:16:41 -0700 Subject: [PATCH 6/8] Update undiscord-core.js --- src/undiscord-core.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index a81fade5..becd4012 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -316,9 +316,7 @@ class UndiscordCore { // if the user provided an author.Id and doesn't wish to include applications, skip all messages that aren't created by the author.Id. // fixes issues with bots & applications hanging the deletion if (this.options.includeApplications == false) { - log.verb("IncludeApplications filter is false. Skipping bots and applications...") - } - if (this.options.includeApplications == false) { + log.verb("Include Applications is false. Skipping bots and applications...") messagesToDelete = messagesToDelete.filter(msg => !msg.author.bot); } // custom filter of messages From d276434ec79a567984a36ce1f6a34d2c5b6033e4 Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 10:27:47 -0700 Subject: [PATCH 7/8] fix semicolon --- src/undiscord-core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index becd4012..32c82ba9 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -316,7 +316,7 @@ class UndiscordCore { // if the user provided an author.Id and doesn't wish to include applications, skip all messages that aren't created by the author.Id. // fixes issues with bots & applications hanging the deletion if (this.options.includeApplications == false) { - log.verb("Include Applications is false. Skipping bots and applications...") + log.verb("Include Applications is false. Skipping bots and applications..."); messagesToDelete = messagesToDelete.filter(msg => !msg.author.bot); } // custom filter of messages From 9e1769b958ad78089e4ac280a3e54461e3427e12 Mon Sep 17 00:00:00 2001 From: falsefox <154926234+false-fox@users.noreply.github.com> Date: Tue, 21 May 2024 11:10:08 -0700 Subject: [PATCH 8/8] fix comment --- src/undiscord-core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/undiscord-core.js b/src/undiscord-core.js index 32c82ba9..1d24ff65 100644 --- a/src/undiscord-core.js +++ b/src/undiscord-core.js @@ -313,7 +313,7 @@ class UndiscordCore { messagesToDelete = messagesToDelete.filter(msg => msg.type === 0 || (msg.type >= 6 && msg.type <= 21)); messagesToDelete = messagesToDelete.filter(msg => msg.pinned ? this.options.includePinned : true); - // if the user provided an author.Id and doesn't wish to include applications, skip all messages that aren't created by the author.Id. + // if the user hasn't checked the include applications option, filter out all bots // fixes issues with bots & applications hanging the deletion if (this.options.includeApplications == false) { log.verb("Include Applications is false. Skipping bots and applications...");