From ec41b867a6fc39f3642361ccdee8f3a3d6b95e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Spie=C3=9F?= Date: Fri, 14 Jul 2023 13:08:10 +0200 Subject: [PATCH] Add the message author id to message reaction events (#2499) --- .../react/MessageReactionAddEvent.java | 29 ++++++++++++++++++- .../handle/MessageReactionHandler.java | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/api/events/message/react/MessageReactionAddEvent.java b/src/main/java/net/dv8tion/jda/api/events/message/react/MessageReactionAddEvent.java index 56ed05719d..db2515f76b 100644 --- a/src/main/java/net/dv8tion/jda/api/events/message/react/MessageReactionAddEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/message/react/MessageReactionAddEvent.java @@ -40,9 +40,36 @@ */ public class MessageReactionAddEvent extends GenericMessageReactionEvent { + private final long messageAuthorId; + public MessageReactionAddEvent(@Nonnull JDA api, long responseNumber, @Nullable User user, - @Nullable Member member, @Nonnull MessageReaction reaction, long userId) + @Nullable Member member, @Nonnull MessageReaction reaction, long userId, long messageAuthorId) { super(api, responseNumber, user, member, reaction, userId); + this.messageAuthorId = messageAuthorId; + } + + /** + * The user id of the original message author. + *
This might be 0 for webhook messages. + * + * @return The user id of the original message author. + */ + @Nonnull + public String getMessageAuthorId() + { + return Long.toUnsignedString(messageAuthorId); + } + + + /** + * The user id of the original message author. + *
This might be 0 for webhook messages. + * + * @return The user id of the original message author. + */ + public long getMessageAuthorIdLong() + { + return messageAuthorId; } } diff --git a/src/main/java/net/dv8tion/jda/internal/handle/MessageReactionHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/MessageReactionHandler.java index 5af5a40cf0..5e4178b425 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/MessageReactionHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/MessageReactionHandler.java @@ -176,7 +176,7 @@ protected Long handleInternally(DataObject content) api.handleEvent( new MessageReactionAddEvent( api, responseNumber, - user, member, reaction, userId)); + user, member, reaction, userId, content.getUnsignedLong("message_author_id", 0L))); } else {