createDm method

Future<DmChannel> createDm(
  1. Snowflake recipientId
)

Create a DM channel with another user.

Implementation

Future<DmChannel> createDm(Snowflake recipientId) async {
  final route = HttpRoute()
    ..users(id: '@me')
    ..channels();
  final request = BasicRequest(route, method: 'POST', body: jsonEncode({'recipient_id': recipientId.toString()}));

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

  client.updateCacheWith(channel);
  return channel;
}