fetch method

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

Fetch the item with the given id from the API.

Implementers should ensure this method updates the cache.

Implementation

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

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

  client.updateCacheWith(event);
  return event;
}