Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application Commands fix. #629

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ui/undiscord.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ <h3>Undiscord</h3>
<div class="sectionDescription">
<label><input id="includePinned" type="checkbox">Include pinned</label>
</div>
<div class="sectionDescription">
<label><input id="includeApplications" type="checkbox">Include Applications</label>
</div>
</fieldset>
<hr>
<fieldset>
Expand Down
11 changes: 9 additions & 2 deletions src/undiscord-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, //Include application/bot messages
deleteDelay: null, // Delay between each delete operation
maxAttempt: 2, // Attempts to delete a single message if it fails
askForConfirmation: true,
Expand Down Expand Up @@ -311,8 +312,14 @@ 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);

// custom filter of messages

// 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...");
messagesToDelete = messagesToDelete.filter(msg => !msg.author.bot);
}
// custom filter of messages
try {
const regex = new RegExp(this.options.pattern, 'i');
messagesToDelete = messagesToDelete.filter(msg => regex.test(msg.content));
Expand Down
6 changes: 4 additions & 2 deletions src/undiscord-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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').checked;
// message interval
const minId = $('input#minId').value.trim();
const maxId = $('input#maxId').value.trim();
Expand All @@ -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.
Expand All @@ -291,6 +292,7 @@ async function startAction() {
content,
hasLink,
hasFile,
includeApplications,
includeNsfw,
includePinned,
pattern,
Expand Down Expand Up @@ -345,4 +347,4 @@ function stopAction() {

export default initUI;

// ---- END Undiscord ----
// ---- END Undiscord ----