Skip to content

Commit

Permalink
feat(model, gateway): add message_author_id for reaction add events (
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni authored Jul 16, 2023
1 parent 3d64938 commit ee22c3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions twilight-cache-inmemory/src/event/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ mod tests {
},
guild_id: Some(Id::new(1)),
member: None,
message_author_id: None,
message_id: Id::new(4),
user_id: Id::new(5),
}));
Expand All @@ -201,6 +202,7 @@ mod tests {
},
guild_id: Some(Id::new(1)),
member: None,
message_author_id: None,
message_id: Id::new(4),
user_id: Id::new(5),
}));
Expand Down
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn cache_with_message_and_reactions() -> InMemoryCache {
verified: None,
},
}),
message_author_id: Some(Id::new(7)),
message_id: Id::new(4),
user_id: Id::new(3),
});
Expand Down
17 changes: 15 additions & 2 deletions twilight-model/src/gateway/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct GatewayReaction {
pub emoji: ReactionType,
pub guild_id: Option<Id<GuildMarker>>,
pub member: Option<Member>,
/// ID of the user who authored the message which was reacted to.
#[serde(skip_serializing_if = "Option::is_none")]
pub message_author_id: Option<Id<UserMarker>>,
pub message_id: Id<MessageMarker>,
pub user_id: Id<UserMarker>,
}
Expand Down Expand Up @@ -74,6 +77,7 @@ mod tests {
verified: None,
},
}),
message_author_id: Some(Id::new(7)),
message_id: Id::new(3),
user_id: Id::new(4),
};
Expand All @@ -83,7 +87,7 @@ mod tests {
&[
Token::Struct {
name: "GatewayReaction",
len: 6,
len: 7,
},
Token::Str("channel_id"),
Token::NewtypeStruct { name: "Id" },
Expand Down Expand Up @@ -152,6 +156,10 @@ mod tests {
Token::Str("test"),
Token::StructEnd,
Token::StructEnd,
Token::Str("message_author_id"),
Token::Some,
Token::NewtypeStruct { name: "Id" },
Token::Str("7"),
Token::Str("message_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("3"),
Expand All @@ -173,6 +181,7 @@ mod tests {
guild_id: None,
member: None,
message_id: Id::new(3),
message_author_id: Some(Id::new(7)),
user_id: Id::new(4),
};

Expand All @@ -181,7 +190,7 @@ mod tests {
&[
Token::Struct {
name: "GatewayReaction",
len: 6,
len: 7,
},
Token::Str("channel_id"),
Token::NewtypeStruct { name: "Id" },
Expand All @@ -198,6 +207,10 @@ mod tests {
Token::None,
Token::Str("member"),
Token::None,
Token::Str("message_author_id"),
Token::Some,
Token::NewtypeStruct { name: "Id" },
Token::Str("7"),
Token::Str("message_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("3"),
Expand Down
1 change: 1 addition & 0 deletions twilight-standby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ mod tests {
},
guild_id: Some(Id::new(1)),
member: None,
message_author_id: None,
message_id: Id::new(4),
user_id: Id::new(3),
}
Expand Down

0 comments on commit ee22c3b

Please sign in to comment.