I’m late to the party, but theres a function in the tileset called get_custom_data_layer_by_name which returns -1 if it doesnt exist
get_custom_data_layer_by_name
-1