How to query custom post type by term?

You cannot make up your own arguments – rather than replacing the 'category' argument with your taxonomy name, use 'tax_query'.

See “taxonomy parameters” section of the codex on get_posts.

$args = array(
    'post_type' => 'event',
    'post_status' => 'publish',
    'tax_query' => array(
        array(
            'taxonomy' => 'eventcategory',
            'field' => 'slug',
            'terms' => 'nice-events',
        ),
    ),
);


$your_query = get_posts( $args );

// do something with $your_query

Alternatively, you could make use of the WP_Query class:

$args = array(
    'posts_per_page' => -1,
    'post_type' => 'event',
    'post_status' => 'publish',
    'tax_query' => array(
        array(
            'taxonomy' => 'eventcategory',
            'field' => 'slug',
            'terms' => 'nice-events'
        ),
    ),
);


$your_query = new WP_Query( $args );

// do something with $your_query