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

Ended because API returned an empty page (Fix) #218

Open
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions deleteDiscordMessages.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @name Undiscord - Delete all messages in a Discord channel or DM (Bulk deletion)
// @description Extends the discord interface so you can mass delete messages from discord
// @namespace https://github.com/victornpb/deleteDiscordMessages
// @version 4.2
// @version 4.3
// @match https://discord.com/*
// @downloadURL https://raw.githubusercontent.com/victornpb/deleteDiscordMessages/master/deleteDiscordMessages.user.js
// @homepageURL https://github.com/victornpb/deleteDiscordMessages
Expand Down Expand Up @@ -214,10 +214,30 @@ async function deleteMessages(authToken, authorId, guildId, channelId, minId, ma
if (stopHndl && stopHndl() === false) return end(log.error('Stopped by you!'));

return await recurse();
} else {
if (total - offset > 0) log.warn('Ended because API returned an empty page.');
} else {

if (total - offset > 0) {

log.warn(`Offset ${offset}`);

offset += 25;

//log.warn(`Offset ${offset}`);

await wait(searchDelay);

if (stopHndl && stopHndl() === false) return end(log.error('Stopped by you!'));

return await recurse();

log.warn('Ended because API returned an empty page.');

}

return end();

}

}

log.success(`\nStarted at ${start.toLocaleString()}`);
Expand Down