MessageProperties<T extends Channel>.fromJson constructor

MessageProperties<T extends Channel>.fromJson(
  1. T channel,
  2. Map<String, dynamic> json
)

Implementation

factory MessageProperties.fromJson(T channel, Map<String, dynamic> json) {
  final embedSerializer = ioc.resolve<MarshallerContract>().serializers.embed;
  final embeds = List.from(json['embeds'])
      .map((element) => embedSerializer.serialize(element) as MessageEmbed)
      .toList();

  return MessageProperties(
    id: Snowflake(json['id']),
    content: json['content'],
    channelId: json['channel_id'],
    embeds: embeds,
    createdAt: DateTime.parse(json['timestamp']),
    updatedAt: Helper.createOrNull(
        field: json['edited_timestamp'],
        fn: () => DateTime.parse(json['edited_timestamp'])),
  );
}