update method

  1. @override
Future<ApplicationCommand> update(
  1. Snowflake id,
  2. covariant ApplicationCommandUpdateBuilder builder
)
override

Update the item with the given id in the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<ApplicationCommand> update(Snowflake id, ApplicationCommandUpdateBuilder builder) async {
  final route = HttpRoute()..applications(id: applicationId.toString());
  if (_guildId != null) route.guilds(id: _guildId!.toString());
  route.commands(id: id.toString());

  final request = BasicRequest(route, method: 'PATCH', body: jsonEncode(builder.build()));

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

  client.updateCacheWith(command);
  return command;
}