fetchMany method

Future<List<Message>> fetchMany(
  1. {Snowflake? around,
  2. Snowflake? before,
  3. Snowflake? after,
  4. int? limit}
)

Fetch multiple messages in this channel.

Implementation

Future<List<Message>> fetchMany({Snowflake? around, Snowflake? before, Snowflake? after, int? limit}) async {
  final route = HttpRoute()
    ..channels(id: channelId.toString())
    ..messages();
  final request = BasicRequest(
    route,
    queryParameters: {
      if (around != null) 'around': around.toString(),
      if (before != null) 'before': before.toString(),
      if (after != null) 'after': after.toString(),
      if (limit != null) 'limit': limit.toString(),
    },
  );

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

  messages.forEach(client.updateCacheWith);
  return messages;
}