Skip to content

Fix for Wipe Archive Feature API ERROR 50024 - 50021#603

Open
LastPlayerTR wants to merge 2 commits intovictornpb:masterfrom
LastPlayerTR:master
Open

Fix for Wipe Archive Feature API ERROR 50024 - 50021#603
LastPlayerTR wants to merge 2 commits intovictornpb:masterfrom
LastPlayerTR:master

Conversation

@LastPlayerTR
Copy link
Copy Markdown

@ghost
Copy link
Copy Markdown

ghost commented Mar 20, 2024

Great job mate, works well!

@anh9000
Copy link
Copy Markdown

anh9000 commented Mar 22, 2024

How do I use this fix as a non coder? I have the same issue as OP but it's with the normal search and it shows 401

image

Using chrome and the normal "Delete" function to search and delete.
Can the creator push an update or something?

@LastPlayerTR
Copy link
Copy Markdown
Author

LastPlayerTR commented Mar 24, 2024

Hey @anh9000,
Creator needs to accept pr to merge with main undiscord.
But for you I will publish a version
#Edit
As i see you have some token problem.
Create an issue request for that please.

@ghost
Copy link
Copy Markdown

ghost commented May 30, 2024

I want to use the fix, where do I put the code? Using Tampermonkey on Firefox

@LastPlayerTR
Copy link
Copy Markdown
Author

@xeno567
You can compile my repo by this instructions
https://github.com/victornpb/undiscord/blob/master/CONTRIBUTING.md

@ghost
Copy link
Copy Markdown

ghost commented May 30, 2024

@LastPlayerTR
I don't have a lot of clues about coding... Would I have to create my own version that way? Why isn't there just an officially fixed version then? There must be a very simple way and I hope you can explain it to me in even simpler terms ;)

@LastPlayerTR
Copy link
Copy Markdown
Author

Hey @xeno567 ,
Undiscord is a repo everyone can commit and improve it. This section ( Pull Requests ) are commits made by community.
Repo owner needs to merge with main repo this pull requests for a official fix.
Here's a modified version for tampermonkey

https://gist.github.com/LastPlayerTR/dfe1d31d61879ca52a200cd3126d3dfe/raw/860544abd9336d98b3d2676f8a3da7b207e7805d/deleteDiscordMessages.user.js

@ghost
Copy link
Copy Markdown

ghost commented May 30, 2024

@LastPlayerTR
Thanks, so thats a new undiscord script I can paste into Tampermonkey? The stuff at the bottom looks scary, do I need that too?

@LastPlayerTR
Copy link
Copy Markdown
Author

LastPlayerTR commented May 30, 2024

@xeno567 You dont need sourcemapping thing if you mentioned that.
Yeah you can just click the click and install it to your tampermonkey.
Dont forgot to remove old one.

@ghost
Copy link
Copy Markdown

ghost commented May 30, 2024

@LastPlayerTR
Thanks a lot, it worked now, sadly not the way I intended it to, as I apparently have to be in all servers I ever messaged in. But thats a general limitation I guess.

@LastPlayerTR LastPlayerTR changed the title Fix for Wipe Archive Feature ( API ERROR 50024 - 50021 Fix for Wipe Archive Feature API ERROR 50024 - 50021 May 31, 2024
@ghost
Copy link
Copy Markdown

ghost commented Jun 2, 2024

@victornpb Can you please approve this PR?

@victornpb victornpb added the PR looks good Looks like it's good for merging (maybe be in the next release) label Mar 9, 2025
TheCellMaster added a commit to TheCellMaster/undiscord that referenced this pull request Apr 15, 2026
Major refactor: modular architecture + upstream PR features + security fixes.

=== ARCHITECTURE (complete rewrite) ===
- Split monolithic undiscord-core.js (584 lines) into 5 focused modules:
  - src/core/undiscord-core.js: Orchestrator (run, runBatch, stop, confirm)
  - src/core/search.js: Search with iterative retry (202/429 handling)
  - src/core/filter.js: Pure message filtering (types, pinned, bots, threads, regex)
  - src/core/delete.js: Delete with retry loop + rate limit adaptation
  - src/core/unarchive.js: Thread unarchive before delete
- Split monolithic undiscord-ui.js (378 lines) into 4 modules:
  - src/ui/init.js: DOM mount, CSS injection, toolbar button + MutationObserver
  - src/ui/handlers.js: All event handlers (start, stop, getChannel, pick, etc)
  - src/ui/progress.js: onStart/onProgress/onStop callbacks
  - src/ui/logger.js: XSS-safe log rendering with ring buffer
- Created src/api/discord-api.js: Pure fetch layer with AbortSignal.timeout(30s)
- Split helpers.js (8 functions in 8 lines) into semantic modules:
  - src/utils/time.js: wait(), msToHMS()
  - src/utils/html.js: escapeHTML(), redact(), replaceInterpolations()
  - src/utils/discord.js: queryString(), ask(), toSnowflake()
- Merged createElm.js + insertCss.js into src/utils/dom.js
- Split CSS (theme.css 355 lines + main.css 172 lines) into 6 modules:
  - layout.css, components.css, scrollbar.css, redact.css, log.css, drag.css
- Moved HTML templates to src/ui/html/
- Renamed utils to kebab-case (getIds -> get-ids, messagePicker -> message-picker)
- Removed 12 legacy files replaced by modular architecture
- Created src/utils/constants.js with shared constants

=== NEW FEATURES (from upstream PRs) ===
- victornpb#741: Poll messages (type 46) can now be deleted
- victornpb#741: Bot slash command responses (type 20) excluded from deletion
- victornpb#742: HTTP 403 on delete returns FAIL_SKIP instead of infinite retry loop
- victornpb#743: Retry logic refactored: FAILED/FAIL_SKIP properly handled, failCount centralized
- victornpb#740: HTTP 403 on search gracefully skips channel instead of canceling batch
- victornpb#739: 30s delay between batch jobs to prevent API spam
- victornpb#737: Thread unarchiving: attempts PATCH to unarchive before skipping
- victornpb#729: Empty page retries (configurable, default 2) before stopping
- victornpb#629: "Include bot/application messages" checkbox in Filter section
- victornpb#610: Thread auto-detection via API when clicking "current" channel button
- victornpb#603: Graceful handling of API errors 50024 (channel not found) and 50001 (missing access)
- victornpb#643: Date filter warning: "Make sure you enter both date AND time"
- victornpb#527/victornpb#519: Rate limit delay adds on top (never decreases) with caps

=== SECURITY FIXES ===
- S1 XSS fix: printLog now escapes all external data via escapeHTML(),
  preserving <x> redact tags via split pattern for streamer mode
- escapeHTML() now also escapes > character
- Log type validated against whitelist before becoming CSS class name
- AbortSignal.timeout(30s) on ALL fetch calls (search, delete, unarchive, getChannel)
  replacing leaky setTimeout-based AbortController
- retry_after clamped with Math.max(w, 0) to prevent negative values causing tight loops

=== BUG FIXES ===
- Fixed onStop called twice (stop() + end of run()) via guard check
- Fixed missing return DELETE_RESULT.FAILED in JSON.parse catch path
- Fixed filterResponse was async unnecessarily (now sync)
- Fixed _searchResponse null crash with guard in filterResponse
- Fixed .filter(Boolean) after map().find() to prevent undefined entries
- Fixed replaceInterpolations treating falsy values (0, false, "") as missing (|| -> ??)

=== QUALITY IMPROVEMENTS ===
- DELETE_RESULT enum (Object.freeze) replaces magic strings
- DELETABLE_MSG_TYPES Set replaces compound conditional
- Set-based lookup for skipped messages (O(n) vs O(n^2))
- search() converted from recursive to iterative with MAX_SEARCH_RETRIES=20
- searchDelay capped at MAX_SEARCH_DELAY_MS (60s)
- deleteDelay capped at MAX_DELETE_DELAY_MS (30s)
- Log ring buffer: MAX_LOG_ENTRIES=5000 prevents unbounded DOM growth
- Confirm preview limited to 10 messages
- messagePicker timeout (30s) with automatic cleanup
- drag.css selectors scoped with #undiscord
- .resize-handle scoped with #undiscord
- Orphan .logarea CSS class removed
- MutationObserver throttle extracted to OBSERVER_THROTTLE_MS constant
- All CSS variables use fallback pattern var(--new, var(--old))
- JSDoc on all public methods

=== BUILD ===
- metadata.mjs supports contributors array from package.json
- @author now shows both victornpb and TheCellMaster
- CLAUDE.md created with project documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR looks good Looks like it's good for merging (maybe be in the next release)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants