createGroupDm method

Future<GroupDmChannel> createGroupDm(
  1. List<String> tokens,
  2. Map<Snowflake, String> nicks
)

Create a DM channel with multiple other users.

Implementation

Future<GroupDmChannel> createGroupDm(List<String> tokens, Map<Snowflake, String> nicks) async {
  final route = HttpRoute()
    ..users(id: '@me')
    ..channels();
  final request = BasicRequest(
    route,
    method: 'POST',
    body: jsonEncode({
      'access_tokens': tokens,
      'nicks': {
        for (final entry in nicks.entries) entry.key.toString(): entry.value,
      }
    }),
  );

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

  client.updateCacheWith(channel);
  return channel;
}