fetch method

  1. @override
Future<ApplicationCommand> fetch(
  1. Snowflake id
)
override

Fetch the item with the given id from the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<ApplicationCommand> fetch(Snowflake id) 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);

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

  client.updateCacheWith(command);
  return command;
}