listCommands method

Future<List<MmCommand>?> listCommands({
  1. String? teamId,
  2. bool? customOnly,
})

List commands for a team

List commands for a team. ##### Permissions manage_slash_commands if need list custom commands.

Parameters:

  • String teamId: The team id.

  • bool customOnly: To get only the custom commands. If set to false will get the custom if the user have access plus the system commands, otherwise just the system commands.

Implementation

Future<List<MmCommand>?> listCommands({
  String? teamId,
  bool? customOnly,
}) async {
  final response = await listCommandsWithHttpInfo(
    teamId: teamId,
    customOnly: customOnly,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<MmCommand>') as List).cast<MmCommand>().toList();
  }
  return null;
}