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

Dont override latest message id on deletion event #2013

Merged
merged 4 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public interface MessageChannel extends Channel, Formattable
* <br>This should only be used if {@link #hasLatestMessage()} returns {@code true}!
*
* <p>This value is updated on each {@link net.dv8tion.jda.api.events.message.MessageReceivedEvent MessageReceivedEvent}
* and <u><b>will be reset to {@code null} if the message associated with this ID gets deleted</b></u>
* and <u><b>the value might point to an already deleted message since the ID is not cleared when the message is deleted,
* so calling {@link #retrieveMessageById(long)} with this id can throw {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}</b></u>
DV8FromTheWorld marked this conversation as resolved.
Show resolved Hide resolved
*
* @throws java.lang.IllegalStateException
* If no message id is available
Expand All @@ -109,7 +110,8 @@ default String getLatestMessageId()
* <br>This should only be used if {@link #hasLatestMessage()} returns {@code true}!
*
* <p>This value is updated on each {@link net.dv8tion.jda.api.events.message.MessageReceivedEvent MessageReceivedEvent}
* and <u><b>will be reset to {@code null} if the message associated with this ID gets deleted</b></u>
* and <u><b>the value might point to an already deleted message since the value is not cleared when the message is deleted,
* so calling {@link #retrieveMessageById(long)} with this id can throw {@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}</b></u>
DV8FromTheWorld marked this conversation as resolved.
Show resolved Hide resolved
*
* @throws java.lang.IllegalStateException
* If no message id is available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ protected Long handleInternally(DataObject content)
return null;
}

// Reset the latest message id as it was deleted.
if (channel.hasLatestMessage() & messageId == channel.getLatestMessageIdLong())
{
((MessageChannelMixin<?>) channel).setLatestMessageIdLong(0);
}

if (channel.getType().isThread())
{
ThreadChannelImpl gThread = (ThreadChannelImpl) channel;
Expand Down