parseGroupDmChannel method

GroupDmChannel parseGroupDmChannel(
  1. Map<String, Object?> raw, {
  2. Snowflake? guildId,
})

Implementation

GroupDmChannel parseGroupDmChannel(Map<String, Object?> raw, {Snowflake? guildId}) {
  assert(raw['type'] == ChannelType.groupDm.value, 'Invalid type for GroupDmChannel');

  return GroupDmChannel(
    id: Snowflake.parse(raw['id']!),
    manager: this,
    name: raw['name'] as String,
    recipients: parseMany(raw['recipients'] as List, client.users.parse),
    iconHash: raw['icon'] as String?,
    ownerId: Snowflake.parse(raw['owner_id']!),
    applicationId: maybeParse(raw['application_id'], Snowflake.parse),
    isManaged: raw['managed'] as bool? ?? false,
    lastMessageId: maybeParse(raw['last_message_id'], Snowflake.parse),
    lastPinTimestamp: maybeParse(raw['last_pin_timestamp'], DateTime.parse),
    rateLimitPerUser: maybeParse<Duration?, int>(raw['rate_limit_per_user'], (value) => value == 0 ? null : Duration(seconds: value)),
  );
}