bulkOverride method

Future<List<ApplicationCommand>> bulkOverride(
  1. List<ApplicationCommandBuilder> builders
)

Remove all existing commands and replace them with the commands defined in builders.

Implementation

Future<List<ApplicationCommand>> bulkOverride(List<ApplicationCommandBuilder> builders) async {
  final route = HttpRoute()..applications(id: applicationId.toString());
  if (_guildId != null) route.guilds(id: _guildId!.toString());
  route.commands();

  final request = BasicRequest(route, method: 'PUT', body: jsonEncode([for (final builder in builders) builder.build()]));

  final response = await client.httpHandler.executeSafe(request);
  final commands = parseMany(response.jsonBody as List, parse);

  cache.clear();
  commands.forEach(client.updateCacheWith);
  return commands;
}