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

fix: stopping run when messages remain #619

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/undiscord-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class UndiscordCore {
this.calcEtr();
log.verb(`Estimated time remaining: ${msToHMS(this.stats.etr)}`);

const messagesRemaining = this.state.grandTotal - this.state.offset;
// if there are messages to delete, delete them
if (this.state._messagesToDelete.length > 0) {

Expand All @@ -169,6 +170,9 @@ class UndiscordCore {
log.verb('There\'s nothing we can delete on this page, checking next page...');
log.verb(`Skipped ${this.state._skippedMessages.length} out of ${this.state._seachResponse.messages.length} in this page.`, `(Offset was ${oldOffset}, ajusted to ${this.state.offset})`);
}
else if (this.state.delCount < messagesRemaining) {
log.verb('There\'s messages remaining, checking next page...');
}
else {
log.verb('Ended because API returned an empty page.');
log.verb('[End state]', this.state);
Expand Down