From 57dc32826081d60ec4fd905c939b15afe7dc7abe Mon Sep 17 00:00:00 2001 From: Lexie Date: Sat, 12 Oct 2024 12:30:25 +0200 Subject: [PATCH] add new fields on message snapshot (#716) --- lib/src/http/managers/message_manager.dart | 6 ++++-- lib/src/models/message/message.dart | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/src/http/managers/message_manager.dart b/lib/src/http/managers/message_manager.dart index b26203714..b19897232 100644 --- a/lib/src/http/managers/message_manager.dart +++ b/lib/src/http/managers/message_manager.dart @@ -93,10 +93,10 @@ class MessageManager extends Manager { parseMessageInteractionMetadata, ), thread: maybeParse(raw['thread'], client.channels.parse) as Thread?, - components: maybeParseMany(raw['components'], parseMessageComponent), + components: snapshot.components, position: raw['position'] as int?, roleSubscriptionData: maybeParse(raw['role_subscription_data'], parseRoleSubscriptionData), - stickers: parseMany(raw['sticker_items'] as List? ?? [], client.stickers.parseStickerItem), + stickers: snapshot.stickers, resolved: maybeParse(raw['resolved'], (Map raw) => client.interactions.parseResolvedData(raw, guildId: guildId, channelId: channelId)), poll: maybeParse(raw['poll'], parsePoll), call: maybeParse(raw['call'], parseMessageCall), @@ -406,6 +406,8 @@ class MessageManager extends Manager { // https://github.com/discord/discord-api-docs/issues/7193 roleMentionIds: maybeParseMany(raw['mention_roles'] as List?, Snowflake.parse) ?? [], type: MessageType(raw['type'] as int), + stickers: parseMany(raw['sticker_items'] as List? ?? [], client.stickers.parseStickerItem), + components: maybeParseMany(raw['components'], parseMessageComponent), ); } diff --git a/lib/src/models/message/message.dart b/lib/src/models/message/message.dart index c4a78debc..e730098c8 100644 --- a/lib/src/models/message/message.dart +++ b/lib/src/models/message/message.dart @@ -181,10 +181,10 @@ class Message extends PartialMessage implements MessageSnapshot { /// The thread that was started from this message if any, `null` otherwise. final Thread? thread; - /// A list of components in this message. + @override final List? components; - /// List of sticker attached to message + @override final List stickers; /// A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of this message in a thread. @@ -492,6 +492,12 @@ class MessageSnapshot with ToStringHelper { /// A list of roles mentioned in the message. final List roleMentionIds; + /// A list of Stickers attached to this message. + final List stickers; + + /// A list of components in this message. + final List? components; + /// @nodoc MessageSnapshot({ required this.timestamp, @@ -503,6 +509,8 @@ class MessageSnapshot with ToStringHelper { required this.flags, required this.mentions, required this.roleMentionIds, + required this.stickers, + required this.components, }); }