Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
changed the version
  • Loading branch information
JoshiCodes committed Jun 9, 2023
1 parent e22f672 commit 294aafb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.joshicodes</groupId>
<artifactId>rja</artifactId>
<version>1.0-alpha.8f</version>
<version>1.0-alpha.9</version>

<description>
Simple Java API for Revolt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
public class MessageReceivedEvent extends IncomingEvent {

public MessageReceivedEvent() {
this(null, null, null);
this(null, null, null, null);
}

private final TextChannel channel;
private final User author;
private final Message message;

public MessageReceivedEvent(RJA rja, User author, Message message) {
public MessageReceivedEvent(RJA rja, User author, Message message, TextChannel channel) {
super(rja, "Message");
this.author = author;
this.message = message;
this.channel = channel;
}

public TextChannel getChannel() {
return channel;
}

public User getAuthor() {
Expand Down Expand Up @@ -63,12 +69,16 @@ public MessageReceivedEvent handle(RJA rja, JsonObject object) {
Message message = Message.from(rja, object, null);
rja.cacheMessage(message);
// update cached channel
TextChannel textChannel = null;
if(message.getChannel().complete() instanceof TextChannel tc) {
textChannel = tc;
}
rja.getChannelCache().stream().filter(c -> c.getId().equals(message.getChannelId())).findFirst().ifPresent(c -> {
if(c instanceof TextChannel tc) {
TextChannel.updateLastMessageId(tc, message.getId());
}
});
return new MessageReceivedEvent(rja, author, message);
return new MessageReceivedEvent(rja, author, message, textChannel);
}

}

0 comments on commit 294aafb

Please sign in to comment.