DmChannel.fromPayload constructor

DmChannel.fromPayload(
  1. dynamic payload
)

Implementation

factory DmChannel.fromPayload(dynamic payload) {
  final userManager = DmUserManager(payload['id']);

  if (payload['recipients'] != null) {
    for (dynamic element in payload['recipients']) {
      User? user = ioc.use<MineralClient>().users.cache.get(element['id']);

      if (user != null) {
        userManager.cache.putIfAbsent(user.id, () => DmUser.fromUser(user, payload['id']));
      }
    }
  }

  return DmChannel(
    payload['last_message_id'],
    MessageManager(null, payload['id']),
    userManager,
    payload['id'],
  );
}