Skip to content

Commit

Permalink
Fix for Wipe Archive victornpb#601
Browse files Browse the repository at this point in the history
  • Loading branch information
Last's VSCode committed Mar 7, 2024
1 parent 9ce4d7b commit 7bb6d14
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/undiscord-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class UndiscordCore {
do {
this.state.iterations++;

console.log(this)

log.verb('Fetching messages...');
// Search messages
await this.search();
Expand Down Expand Up @@ -285,6 +287,30 @@ class UndiscordCore {
await wait(w * 2);
return await this.search();
}
if (resp.status === 400 ) {
const data = await resp.json();
if (data.code === 50024) {
// 400 can happen if the channel is not found (code=50024)
log.error('Error searching messages, channel not found!');
// return fake empty messages data to skip the next channel
const data = { total_results: 0, messages: [] };
this.state._seachResponse = data;
return data;

}

}
if (resp.status === 403) {
const data = await resp.json();
if (data.code === 50001) {
// 403 can happen if the bot is not in the guild (code=50001)
log.error('Error searching messages, user is not in the guild!');
// return fake empty messages data to skip the next channel
const data = { total_results: 0, messages: [] };
this.state._seachResponse = data;
return data;
}
}
else {
this.state.running = false;
log.error(`Error searching messages, API responded with status ${resp.status}!\n`, await resp.json());
Expand Down

0 comments on commit 7bb6d14

Please sign in to comment.