PermissionOverwrite.from constructor

PermissionOverwrite.from({
  1. required dynamic payload,
})

Implementation

factory PermissionOverwrite.from({required dynamic payload}) {
  return PermissionOverwrite(
    id: payload['id'],
    type: payload['type'] is String
      ? PermissionOverwriteType.values.firstWhere((element) => element.name == payload['type'])
      : PermissionOverwriteType.values.firstWhere((element) => element.value == payload['type']),
    allow: Helper.bitfieldToPermissions(payload['allow']),
    deny: Helper.bitfieldToPermissions(payload['deny']),
  );
}