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(int.parse(payload['allow'].toString())),
    deny: Helper.bitfieldToPermissions(int.parse(payload['deny'].toString())),
  );
}