getSession method

Future<Map<String, dynamic>> getSession(
  1. String sessionId
)

Get session information

Implementation

Future<Map<String, dynamic>> getSession(String sessionId) async {
  LavalinkLogger.debug('Getting session info', tag: 'REST');

  try {
    final uri = Uri.parse('$baseUrl/v4/sessions/$sessionId');

    final request = await _httpClient.getUrl(uri);
    _addHeaders(request);

    final response = await request.close();
    final responseBody = await _readResponse(response);

    if (response.statusCode != 200) {
      throw LavalinkException(
        'Failed to get session: ${response.statusCode}',
        statusCode: response.statusCode,
      );
    }

    return jsonDecode(responseBody) as Map<String, dynamic>;
  } catch (e) {
    if (e is LavalinkException) rethrow;
    throw LavalinkException('Failed to get session: $e', cause: e);
  }
}