Skip to content

Commit

Permalink
add new fields on message snapshot (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexedia authored Oct 12, 2024
1 parent e10d0ff commit 57dc328
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/src/http/managers/message_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class MessageManager extends Manager<Message> {
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<String, Object?> raw) => client.interactions.parseResolvedData(raw, guildId: guildId, channelId: channelId)),
poll: maybeParse(raw['poll'], parsePoll),
call: maybeParse(raw['call'], parseMessageCall),
Expand Down Expand Up @@ -406,6 +406,8 @@ class MessageManager extends Manager<Message> {
// 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),
);
}

Expand Down
12 changes: 10 additions & 2 deletions lib/src/models/message/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessageComponent>? components;

/// List of sticker attached to message
@override
final List<StickerItem> stickers;

/// A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of this message in a thread.
Expand Down Expand Up @@ -492,6 +492,12 @@ class MessageSnapshot with ToStringHelper {
/// A list of roles mentioned in the message.
final List<Snowflake> roleMentionIds;

/// A list of Stickers attached to this message.
final List<StickerItem> stickers;

/// A list of components in this message.
final List<MessageComponent>? components;

/// @nodoc
MessageSnapshot({
required this.timestamp,
Expand All @@ -503,6 +509,8 @@ class MessageSnapshot with ToStringHelper {
required this.flags,
required this.mentions,
required this.roleMentionIds,
required this.stickers,
required this.components,
});
}

Expand Down

0 comments on commit 57dc328

Please sign in to comment.