startGuildPrune method

Future<int?> startGuildPrune(
  1. Snowflake id, {
  2. int? days,
  3. bool? computeCount,
  4. List<Snowflake>? roleIds,
  5. String? auditLogReason,
})

Start a prune in a guild.

Implementation

Future<int?> startGuildPrune(
  Snowflake id, {
  int? days,
  bool? computeCount,
  List<Snowflake>? roleIds,
  String? auditLogReason,
}) async {
  final route = HttpRoute()
    ..guilds(id: id.toString())
    ..prune();
  final request = BasicRequest(
    route,
    method: 'POST',
    auditLogReason: auditLogReason,
    body: jsonEncode({
      if (days != null) 'days': days,
      if (computeCount != null) 'compute_prune_count': computeCount,
      if (roleIds != null) 'include_roles': roleIds.map((e) => e.toString()).toList(),
    }),
  );

  final response = await client.httpHandler.executeSafe(request);
  return (response.jsonBody as Map<String, Object?>)['pruned'] as int?;
}