parseDmChannel method

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

Implementation

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

  return DmChannel(
    id: Snowflake.parse(raw['id']!),
    manager: this,
    recipient: client.users.parse((raw['recipients'] as List).single as Map<String, Object?>),
    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)),
  );
}