create method

  1. @override
Future<Webhook> create(
  1. covariant WebhookBuilder 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<Webhook> create(WebhookBuilder builder, {String? auditLogReason}) async {
  final route = HttpRoute()
    ..channels(id: builder.channelId.toString())
    ..webhooks();
  final request = BasicRequest(route, method: 'POST', body: jsonEncode(builder.build()), auditLogReason: auditLogReason);

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

  client.updateCacheWith(webhook);
  return webhook;
}