importJson method

EmbedBuilder importJson(
  1. RawApiMap raw
)

Returns a EmbedBuilder with data from the raw json

Implementation

EmbedBuilder importJson(RawApiMap raw) {
  this.title = raw["title"] as String?;
  this.description = raw["description"] as String?;
  this.url = raw["url"] as String?;
  this.color = raw["color"] != null ? DiscordColor.fromInt(raw["color"] as int) : null;
  this.timestamp = raw["timestamp"] != null ? DateTime.parse(raw["timestamp"] as String) : null;
  this.footer = raw["footer"] != null
      ? EmbedFooterBuilder().importJson(raw["footer"] as Map<String, String?>)
      : null;
  this.imageUrl = raw["image"]["url"] as String?;
  this.thumbnailUrl = raw["thumbnail"]["url"] as String?;
  this.author = raw["author"] != null
      ? EmbedAuthorBuilder().importJson(raw["author"] as Map<String, String?>)
      : null;

  for(final rawFields in raw["fields"] as List<dynamic>) {
    this.fields.add(EmbedFieldBuilder().importJson(rawFields as RawApiMap));
  }

  return this;
}