update method

  1. @override
Future<AutoModerationRule> update(
  1. Snowflake id,
  2. covariant AutoModerationRuleUpdateBuilder builder, {
  3. String? auditLogReason,
})
override

Update the item with the given id in the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<AutoModerationRule> update(Snowflake id, AutoModerationRuleUpdateBuilder builder, {String? auditLogReason}) async {
  final route = HttpRoute()
    ..guilds(id: guildId.toString())
    ..autoModeration()
    ..rules(id: id.toString());
  final request = BasicRequest(route, method: 'PATCH', body: jsonEncode(builder.build()), auditLogReason: auditLogReason);

  final response = await client.httpHandler.executeSafe(request);
  final rule = parse(response.jsonBody as Map<String, Object?>);

  client.updateCacheWith(rule);
  return rule;
}