fetch method

  1. @override
Future<Guild> fetch(
  1. Snowflake id, {
  2. bool? withCounts,
})
override

Fetch the item with the given id from the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<Guild> fetch(Snowflake id, {bool? withCounts}) async {
  final route = HttpRoute()..guilds(id: id.toString());
  final request = BasicRequest(route, queryParameters: {if (withCounts != null) 'with_counts': withCounts.toString()});

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

  client.updateCacheWith(guild);
  return guild;
}