create method

  1. @override
Future<AutoModerationRule> create(
  1. covariant AutoModerationRuleBuilder builder,
  2. {String? auditLogReason}
)
override

Create a new instance of the type of this manager.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<AutoModerationRule> create(AutoModerationRuleBuilder builder, {String? auditLogReason}) async {
  final route = HttpRoute()
    ..guilds(id: guildId.toString())
    ..autoModeration()
    ..rules();
  final request = BasicRequest(route, method: 'POST', 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;
}